How to: |
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 more information, see Calling a Function From a Dialogue Manager Command
DATEMOV works only with full component dates.
DATEMOV(date, 'move-point')
where:
Date
Is the date to be moved. It must be a full component format date (for example, MDYY or YYJUL).
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 is the end of month.
BOM is the beginning of month.
EOQ is the end of quarter.
BOQ is the beginning of quarter.
EOY is the end of year.
BOY is the beginning of year.
EOW is the end of week.
BOW is the beginning of week.
NWD is the next weekday.
NBD is the next business day.
PWD is the prior weekday.
PBD is the prior business day.
WD- is a weekday or earlier.
BD- is a business day or earlier.
WD+ is a weekday or later.
BD+ is a business day or later.
A business day calculation is affected by the BUSDAYS and HDAY parameter settings.
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.
The BUSDAYS parameter sets the business days to Monday, Tuesday, Wednesday, and Thursday. DATECVT converts the legacy date HIRE_DATE to the date format YYMD and provides date display options. DATEMOV then determines significant points for HIRE_DATE.
SET BUSDAY = _MTWT__ TABLE FILE EMPLOYEE PRINT COMPUTE NEW_DATE/YYMD = DATECVT(HIRE_DATE, 'I6YMD', 'YYMD'); AND COMPUTE NEW_DATE/WT = DATECVT(HIRE_DATE, 'I6YMD', 'WT'); AS 'DOW' AND COMPUTE NWD/WT = DATEMOV(NEW_DATE, 'NWD'); AND COMPUTE PWD/WT = DATEMOV(NEW_DATE, 'PWD'); AND COMPUTE WDP/WT = DATEMOV(NEW_DATE, 'WD+'); AS 'WD+' AND COMPUTE WDM/WT = DATEMOV(NEW_DATE, 'WD-'); AS 'WD-' AND COMPUTE NBD/WT = DATEMOV(NEW_DATE, 'NBD'); AND COMPUTE PBD/WT = DATEMOV(NEW_DATE, 'PBD'); AND COMPUTE WBP/WT = DATEMOV(NEW_DATE, 'BD+'); AS 'BD+' AND COMPUTE WBM/WT = DATEMOV(NEW_DATE, 'BD-'); AS 'BD-' BY LAST_NAME NOPRINT HEADING "Examples of DATEMOV" "Business days are Monday, Tuesday, Wednesday, + Thursday " " " "START DATE.. | MOVE POINTS..........................." WHERE DEPARTMENT EQ 'MIS'; END
The output is:
Examples of DATEMOV Business days are Monday, Tuesday, Wednesday, + Thursday START DATE.. | MOVE POINTS........................... NEW_DATE DOW NWD PWD WD+ WD- NBD PBD BD+ BD- -------- --- --- --- --- --- --- --- --- --- 1982/04/01 THU FRI WED THU THU MON WED THU THU 1981/11/02 MON TUE FRI MON MON TUE THU MON MON 1982/04/01 THU FRI WED THU THU MON WED THU THU 1982/05/01 SAT TUE THU MON FRI TUE WED MON THU 1981/07/01 WED THU TUE WED WED THU TUE WED WED 1981/07/01 WED THU TUE WED WED THU TUE WED WED
DATEMOV determines the end of the week for each date in NEW_DATE and stores the result in EOW:
TABLE FILE EMPLOYEE
PRINT FIRST_NAME AND
COMPUTE NEW_DATE/YYMDWT = DATECVT(HIRE_DATE, 'I6YMD', 'YYMDWT'); AND
COMPUTE EOW/YYMDWT = DATEMOV(NEW_DATE, 'EOW');
BY LAST_NAME
WHERE DEPARTMENT EQ 'PRODUCTION';
END
The output is:
LAST_NAME FIRST_NAME NEW_DATE EOW --------- ---------- -------- --- BANNING JOHN 1982 AUG 1, SUN 1982 AUG 6, FRI IRVING JOAN 1982 JAN 4, MON 1982 JAN 8, FRI MCKNIGHT ROGER 1982 FEB 2, TUE 1982 FEB 5, FRI ROMANS ANTHONY 1982 JUL 1, THU 1982 JUL 2, FRI SMITH RICHARD 1982 JAN 4, MON 1982 JAN 8, FRI STEVENS ALFRED 1980 JUN 2, MON 1980 JUN 6, FRI
DATEMOV determines the end of the week for each date:
MAINTAIN
COMPUTE X/YYMDWT='20020717';
COMPUTE Y/YYMDWT=DATEMOV(X, 'EOW', Y);
TYPE "<<X <<Y END OF WEEK "
END
The result is:
2002/07/17, WED 2002/07/19, FRI END OF WEEK
WebFOCUS |