9.34 DATEDIFFERENCE_ALPHA

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

Note:

For the first and the third argument, the INTEGER and FLOAT field cannot be used.

The DATE field can be used, but it should first be converted into string using the .AsNumber Intrinsic Function.

The value of the second and the fourth argument must be in sync with the format that is put into the intrinsic function.

For example, if you have a DATE field called DATEFL1, and want to use it in the BIF as the first argument, you must do a conversion like this:
DATEFL1.AsNumber(DDMMCCYY) (Refer to the Intrinsic Function for other formats.)

In this example, the value of the second argument should be H, which indicates the DDMMYYYY date format.

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.

Example

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)