Reputation: 347
I have two lines of code which determine the previous quarters start and end dates.
put(INTNX('Quarter',today(),-1,'B'),MMDDYY10.)
put(INTNX('Quarter',today(),-1,'E'),MMDDYY10.)
The Start date above shows as 10/1/2019 The End date above shows as 12/31/2019
However I need to add one month to each date to equal the below.
11/1/2019 1/31/2019
I tried nesting the above in another intnx function but it just returns blank. Thoughts and help would be greatly appreciated.
Upvotes: 0
Views: 590
Reputation: 347
The below works perfectly.
put(INTNX('Month',INTNX('Quarter',today(),-1,'B'),+1,'B'),MMDDYY10.)
put(INTNX('Month',INTNX('Quarter',today(),-1,'E'),+1,'E'),MMDDYY10.)
Upvotes: 1
Reputation: 27508
Try
data _null_;
* compute date values;
* start of second month in prior quarter;
start_date = intnx('MONTH', intnx ('QUARTER', today(), -1, 'B'), 1);
* end of first month after prior quarter;
end_date = intnx('MONTH', intnx ('QUARTER', today(), -1, 'E'), 1, 'E');
* log date values using a desired representation format;
put (start_date end_date) (=mmddyy10./);
* store a date value representation in a variable;
* (this is not typically a desired thing to do);
start_ymd = put (start_date, mmddyy10.);
end_ymd = put (end_date, mmddyy10.);
* log the string values that were forced to represent a date (via PUT);
put start_ymd= / end_ymd=;
run;
Log should show (on 6-jan-2020)
start_date=11/01/2019
end_date=01/31/2020
start_ymd=11/01/2019
end_ymd=01/31/2020
Upvotes: 1