Date variables 

You can calculate (add and subtract days) with date variables ( &D01 to &D10) and parameters which are based on a date data element.

Date formats

You can use the following date formats:

- DD.MM.YYYY         DDMMYYYY

- MM/DD/YYYY         MMDDYYYY

- MM-DD-YYYY         MMDDYYYY

- YYYY.MM.DD          YYYYMMDD

- YYYY.MM.DD          YYYYMMDD

Define your external format in your user master record (default values).

Setting date variables

Set date variables as follows:

Passing date variables

The result of an assignment to a non-date variable is always in external format.

Arithmetic operations with date variables

You can use the following arithmetical operations:

If the first operand is of type DATE and the second is of a different numerical type, a date calculation is performed, i.e. the date in the first operand is incremented by the value of the second operand.

SETVAR

&D01 = SY-DATUM + '30'

 

&D01 = 19931215 + 30

 

&D01 = 19940114

SETVAR

&V01 = '5'

 

&V01 = 5

SETVAR

&D02 = &D01 - &V01

 

&D02 = 19940114 - 5

 

&D02 = 19940109

If both operands in a subtraction are of type DATE and the result is not a date variable, the positive and negative day difference is calculated.

Check and compare date variables

You must specify the execution conditions for the following CATT functions (IF ... ENDIF), for cancellation (EXIT) of a DO/ENDDO loop, and variable contents check conditions (CHEVAR) in the usual form (<variable1> <operand> <variable2>) for date variable checks and comparisons ( See also: Use of conditions).

If at least one of the two variables is a date variable, a date comparison is made. The non-date variable or constant is automatically converted into date format.

SETVAR

&D01 = '31011994'

 

&D01 = 19940131

CHEVAR

&D01 < SY-DATUM

 

19940131 < 19940117

Condition ( &D01 < SY-DATUM ) is not satisfied