Focal Point
[SOLVED]-SET using DATEADD

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2497048086

February 18, 2016, 03:53 PM
Michele Brooks
[SOLVED]-SET using DATEADD
I need to calculate prior 2 months from the current date in YYYY/MM/DD format using a -SET command. Can someone send me an example? Thanks.

This message has been edited. Last edited by: Michele Brooks,


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
February 18, 2016, 04:00 PM
BabakNYC
Here are some basic examples that I have in case I need them. You could tweak them to fit your specific needs.

-SET &&CURDATE=&YYMD;
 
-* This sets what Yesterday is:
-SET &&YESTERDAY=AYMD(&&CURDATE,-1,'I8YYMD');
 
-* This sets Current Year based upon Yesterday
-SET &&CYEAR=EDIT(&&YESTERDAY,'9999');
 
-* This sets Prior Year based upon Yesterday
-SET &&PYEAR=&&CYEAR-1;
 
-* This sets what the current month is based upon todays's date
-SET &&CMONTH=EDIT(&&CURDATE,'999999') || '01';
-SET &CMONTHYYM=EDIT(&&CURDATE,'999999');
 
-* This sets what last month is based upon today's date
-SET &&PMONTH=EDIT(AYM(&CMONTHYYM, -1, 'I6YMD')) || '01';
-SET &PMONTHYYM=EDIT(&&PMONTH,'999999');
 
-* This sets 7 days prior based upon &YESTERDAY
-SET &&P7DAY=AYMD(&&YESTERDAY,-7,'I8YYMD');
 
-* This sets prior 3 months based upon last month - it will generate complete data
-SET &&P3MONTH=EDIT(AYM(&PMONTHYYM, -1,'I6YYM')) || '01';
 
-* This sets prior 6 months based upon last month - it will generate complete data
-SET &&P6MONTH=EDIT(AYM(&PMONTHYYM, -4,'I6YYM')) || '01';
 
-* This sets prior 12 months based upon last month - it will generate complete data
-SET &&P12MONTH=EDIT(AYM(&PMONTHYYM, -12,'I6YYM')) || '01';




WebFOCUS 8206, Unix, Windows
February 18, 2016, 04:15 PM
Tom Flynn
  
-SET &DATE_MINUS_2 = DATECVT(DATEADD(DATECVT(&YYMD,'I8YYMD','YYMD'),'M',-2), 'YYMD', 'I8YYMD');
-TYPE &DATE_MINUS_2
-EXIT



Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
February 19, 2016, 09:06 AM
bug
Very useful, thanks!

quote:
Originally posted by BabakNYC:
Here are some basic examples that I have in case I need them. You could tweak them to fit your specific needs.

-SET &&CURDATE=&YYMD;
 
-* This sets what Yesterday is:
-SET &&YESTERDAY=AYMD(&&CURDATE,-1,'I8YYMD');
 
-* This sets Current Year based upon Yesterday
-SET &&CYEAR=EDIT(&&YESTERDAY,'9999');
 
-* This sets Prior Year based upon Yesterday
-SET &&PYEAR=&&CYEAR-1;
 
-* This sets what the current month is based upon todays's date
-SET &&CMONTH=EDIT(&&CURDATE,'999999') || '01';
-SET &CMONTHYYM=EDIT(&&CURDATE,'999999');
 
-* This sets what last month is based upon today's date
-SET &&PMONTH=EDIT(AYM(&CMONTHYYM, -1, 'I6YMD')) || '01';
-SET &PMONTHYYM=EDIT(&&PMONTH,'999999');
 
-* This sets 7 days prior based upon &YESTERDAY
-SET &&P7DAY=AYMD(&&YESTERDAY,-7,'I8YYMD');
 
-* This sets prior 3 months based upon last month - it will generate complete data
-SET &&P3MONTH=EDIT(AYM(&PMONTHYYM, -1,'I6YYM')) || '01';
 
-* This sets prior 6 months based upon last month - it will generate complete data
-SET &&P6MONTH=EDIT(AYM(&PMONTHYYM, -4,'I6YYM')) || '01';
 
-* This sets prior 12 months based upon last month - it will generate complete data
-SET &&P12MONTH=EDIT(AYM(&PMONTHYYM, -12,'I6YYM')) || '01';




7.66 and 7.704
System: Windows / AIX / Linux
Output: Mostly HTML, with some PDF, Excel and Lotus(!)
February 19, 2016, 09:13 AM
Michele Brooks
Thank you both BabakNYC and Tom. Excellent dialogue manager date routines. I'll definitely keep them in my documentation file for future reference. I'm stuck on one more conversion. I need to do another -SET to get the end of the current month. My DATEMOV calculation is not coming out currently. Thanks again.


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
February 19, 2016, 09:46 AM
Tom Flynn
Same concept, DATEMOV function:
 
-SET &DATE_EOM = DATECVT(DATEMOV(DATECVT(&YYMD,'I8YYMD','YYMD'),EOM), 'YYMD', 'I8YYMD');
-TYPE &DATE_EOM
-EXIT
 



Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
February 19, 2016, 10:11 AM
Kevin W
Is it again time to suggest the document "1001 Way to Work With Dates" by Price and Perlmutter published by Aviter, Inc?


WebFOCUS 7.7.05 (Someday 8)
Windows 7, All Outputs
In Focus since 1983.
February 19, 2016, 10:14 AM
Michele Brooks
Thanks so much Tom. I got it. This is good stuff. These examples are very helpful. You're the man. Thanks again.


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output