Available Languages: reporting, Maintain The DATEMOV function moves a date to a significant point on the calendar. Since Dialogue Manager interprets a date as alphanumeric or numeric, and DATEMOV requires a standard date stored as an offset from the base date, do not use DATEMOV with Dialogue Manager unless you first convert the variable used as the input date to an offset from the base date. For example, the following converts the integer legacy date 20050131 to a smart date, adds one month, and converts the result to an alphanumeric legacy date: -SET &STRT=DATECVT(20050131,'I8YYMD', 'YYMD'); -SET &NMT=DATEADD(&STRT,'M',1); -SET &NMTA=DATECVT(&NMT,'YYMD','A8MTDYY'); -TYPE A MONTH FROM 20050131 IS &NMTA The output shows that the DATEADD function added the actual number of days in the month of February to get to the end of the month from the end of January: A MONTH FROM 20050131 IS 02282005 For more information, see Calling a Function From a Dialogue Manager Command. DATEMOV works only with full component dates. -------------------------------------------------------------------------------- Top of page -------------------------------------------------------------------------------- xx Syntax: How to Move a Date to a Significant Point DATEMOV(date, 'move-point') where: date Date Is the date to be moved. It must be a full component format date (for example, MDYY or YYJUL). move-point Alphanumeric Is the significant point the date is moved to enclosed in single quotation marks. An invalid point results in a return code of zero. Valid values are: EOM, which is the end of month. BOM, wihch is the beginning of month. EOQ, which is the end of quarter. BOQ, which is the beginning of quarter. EOY, which is the end of year. BOY, which is the beginning of year. EOW, which is the end of week. BOW, which is the beginning of week. NWD, which is the next weekday. NBD, which is the next business day. PWD, which is the prior weekday. PBD, which is the prior business day. WD-, which is a weekday or earlier. BD-, which is a business day or earlier. WD+, which is a weekday or later. BD+, which is a business day or later. A business day calculation is affected by the BUSDAYS and HDAY parameter settings. Also note that when the DATEMOV function calculates the next or previous business day or work day, it always starts from a business day or work day. So if the actual day is Saturday or Sunday, and the request wants to calculate the next business day, DATEMOV will use Monday as the starting day, not Saturday or Sunday, and will return Tuesday as the next business day. Similarly, when calculating the previous business day, it will use the starting day Friday, and will return Thursday as the previous business day. To avoid skipping a business day or work day, use DATEMOV twice. To return the next business or work day, use BD- or WD- to first move to the previous business or work day (if it is already a business day or work day, it will not be moved). Then use DATEMOV again to move to the next business or work day. If you want to return the previous business or work day, first use BD+ or WD+ to move to the next business or work day (if it is already the correct type of day, it will not be moved). Then use DATEMOV again to return the previous business or work day. Note: DATEMOV does not use an output argument. It uses the format of the date argument for the result. As long as the result is a full component date, it can be assigned only to a full component date field or to an integer field.
quote:Originally posted by Francis Mariani:
So does this:
-SET &MTDF = DATECVT( DATEMOV(DATECVT(&YYMD,'I8YYMD','YYMD'),'BOM'),'YYMD','I8YYMD');
The innermost DATECVT function call converts the integer value &YYMD to a smart date. Then the DATEMOV function runs and then the outermost DATECVT function converts the smart date back to an integer.
DEFINE FUNCTION UDATEADD(INDATE/A8YYMD, INUNIT/A2, INNBR/I4) INDATE1/YYMD = INDATE; UDATEADD1/YYMD = DATEADD(INDATE1, INUNIT, INNBR); UDATEADD/A8YYMD = UDATEADD1; END -RUN
-SET &DATE1 = UDATEADD(&YYMD, 'M', -3);
In FOCUS Since 1983 ~ from FOCUS to WebFOCUS. Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206 |
-SET &DATEIN = 20150328 ; -* DATEADD(date, 'component', increment) -SET &DATEADD6 = DATEADD(&DATEIN, 'D' , 6 ) ; -TYPE *** &|DATEADD6=&DATEADD6 ***
quote:While I like that DEFINE FUNCTION, why doesn't the following work in WebFOCUS 8, it returns "*** &DATEADD6=20150334 ***"?
-SET &DATEIN = 20150328 ;
-* DATEADD(date, 'component', increment)
-SET &DATEADD6 = DATEADD(&DATEIN, 'D' , 6 ) ;
-TYPE *** &|DATEADD6=&DATEADD6 ***
-SET &DATEIN = 20150328 ; -SET &DATEADD5 = AYMD(&DATEIN,6,'I8'); -TYPE *** &|DATEADD5=&DATEADD5 ***