Page History
9.34 DATEDIFFERENCE_ALPHA
| Note | ||
|---|---|---|
| title | Note: | Built-In Function Rules Usage Options |
Calculates the difference between two given dates in number of days. The return code indicates if the format of the dates or the dates themselves are valid (Y or N). The sign of the calculated value may also be returned.
Arguments
No | Type | Req/ Opt | Description | Min Len | Max Len | Min Dec | Max Dec |
|---|---|---|---|---|---|---|---|
1 | A | Req | Start/First date. See Note. | 1 | 10 | ||
2 | A | Req | Format of Start/First Date | 1 | 1 | ||
3 | A | Req | End/Second date See Note. | 1 | 10 | ||
4 | A | Req | Format of End/Second Date | 1 | 1 |
Valid Date Formats
Valid formats for first and second dates: A, B, C, D, E, F, G, H, I, J, K, L, M, V and 1.
Refer to Date Formats
...
To hold the first return value, any NUMERIC field can be used including INTEGER and FLOAT.
Example RDMLX only:
USE BUILTIN(DATEDIFFERENCE_ALPHA) WITH_ARGS(#DATEFL1. AsNumber(DDMMCCYY) H #DATFL2. AsNumber (CCYYMMDD) J)TO_GET(#DEC80 )
Return Values
No | Type | Req/ Opt | Description | Min Len | Max Len | Min Dec | Max Dec |
|---|---|---|---|---|---|---|---|
1 | N | Req | Difference (beg to end) in days | 3 | 8 | 0 | 0 |
2 | A | Opt | Sign of difference (+,-) | 1 | 1 | ||
3 | A | Opt | Return code (Y, N) for complete. | 1 | 1 |
Note: All dates must have a four character year so that accurate comparisons and calculations can be performed. Where a two character year (e.g. DDMMYY, YYMMDD, MMYY) is supplied the century value is retrieved from the system definition data area. The year supplied is compared to a year in the data area, if the supplied year is less than or equal to the comparison year then the less than century is used. If the supplied year is greater than the comparison year then the greater than century is used.
...
Calculate the difference #DIFF in days between date field #YMD in date format YYMMDD (D) and date field #DMY in date format DDMMYY (B):
USE BUILTIN(DATEDIFFERENCE_ALPHA) WITH_ARGS(#YMD D #DMY B)
...
TO_GET(#DIFF #SIGN)