DATEMOV: Moving a Date to a Significant Point

How to:

The DATEMOV function moves a date to a significant point on the calendar.

DATEMOV works only with full component dates.


Top of page

x
Syntax: How to Move a Date to a Significant Point
DATEMOV(date, 'move-point)

where:

date

Date

Is a full component date. Is the date to be moved.

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 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.



Example: Determining Significant Points for a Date (Reporting)

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  


Example: Determining the End of the Week (Reporting)

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


Example: Determining the End of the Week (Maintain)

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

Information Builders