WebFOCUS MetaDATEs
Problem:
I have a report that needs to run with a date range for the prior month (or maybe for the prior quarter, or some other predictable time period). I could use an autoprompt or a web page built with the Composer to prompt the user for the dates each time it runs. Or, I could DEFINE a series of fields based on the current month, subtracting one, unless the month is 01, in which case I want to use a value of 12, ……. (many steps follow)
Or, I could simply use a few functions……
Solution:
DATECVT - turns alpha information into internal ‘smart date’ equivalents.
DATEADD - adds and subtracts specified blocks of time (months, quarters, etc.)
DATEMOV - contains all kinds of knowledge about how dates relate to each other and how calendars are used
-SET &CURRDT1=DATECVT ( &YYMD , 'I8YYMD' , 'YYMD' ) ;
Take the system variable that contains today’s date (&YYMD) and convert it to the internal, smart date value – the number of days since the base date defined by WebFOCUS.
-SET &LASTMTH=DATEADD(&CURRDT1, 'M', -1);
Use the internal value of today’s date (the result of the previous step), and, going by months (M), subtract one. The result will be the internal date value of the date one month ago.
-SET &BEGIN_MONTH=DATEMOV(&LASTMTH, 'BOM');
Take the date from one month ago (the result of the previous step), and then use the predefined BOM value to find the beginning date of that month.
DATEMOV has many calendar affiliations, allowing you to do this type of operation for many other time periods, just as easily:
BOW, EOW – Beginning and end of work week
BOM, EOM – Beginning and end of month
BOQ, EOQ – Beginning and end of quarter
BOY, EOY – Beginning and end of year
PWD, NWD – Previous and Next weekday
PBD, NBD – Previous and Next business day
If any questions, please contact John at john.kutasz@usbank.com.