英文:
Add month to quarter date
问题
把上面的代码改成下面的样子:
put(INTNX('Quarter', today(), -1, 'B', 'M'), MMDDYY10.)
put(INTNX('Quarter', today(), -1, 'E', 'M'), MMDDYY10.)
英文:
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.
答案1
得分: 1
以下是翻译好的部分:
尝试
数据 _null_;
* 计算日期值;
* 上一季度的第二个月的开始;
start_date = intnx('MONTH', intnx('QUARTER', today(), -1, 'B'), 1);
* 上一季度后的第一个月的结束;
end_date = intnx('MONTH', intnx('QUARTER', today(), -1, 'E'), 1, 'E');
* 使用所需的表示格式记录日期值;
put (start_date end_date) (=mmddyy10./);
* 将日期值表示存储在变量中;
* (通常不建议这样做);
start_ymd = put(start_date, mmddyy10.);
end_ymd = put(end_date, mmddyy10.);
* 记录通过PUT强制表示日期的字符串值;
put start_ymd= / end_ymd=;
run;
日志应显示(在2020年1月6日):
start_date=11/01/2019
end_date=01/31/2020
start_ymd=11/01/2019
end_ymd=01/31/2020
注意:代码部分未被翻译。
英文:
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
答案2
得分: 1
以下部分翻译如下:
下面的部分运行得很好。
`put(INTNX('Month',INTNX('Quarter',today(),-1,'B'),+1,'B'),MMDDYY10.)`
`put(INTNX('Month',INTNX('Quarter',today(),-1,'E'),+1,'E'),MMDDYY10.)`
英文:
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.)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论