Date Functions

Adding / Subtracting a specified number of days to a date

Returning the year and the Julian day

Returning the day of the month

Returning the month

Returning the year

Returning the current date

Returning the number of days between two dates

About Date Functions

You use Date Functions to convert and manipulate date expressions:

  • add / subtract a specified number of days to a date
  • return an integer representing the day of the week or year
  • return a specified portion of a date
  • return the processing date or the current date on the operating system
  • calculate the number of days between two dates

The function syntax depends on the function you want to activate.


$DATEPLUS and $DATEMINUS

Description

$DATEPLUS adds the number of days that you specify to a date.

$DATEMINUS subtracts the number of days that you specify from a date.

The function returns a date. The data type used in the target field must be either:

  • Date
  • Numeric (The length must be compatible with a date, that is N(6), N(7) or N(8))

Syntax

$DATEPLUS(date;number_of_days)

$DATEMINUS(date;number_of_days)

Return

Date

Parameters

You can use any expression that returns a value except a call to the functions DATEPLUS or DATEMINUS.

date
Specify the initial Date value

The data type used for date must be either:

  • Date
  • Numeric (The length must be compatible with a date, that is N(6), N(7) or N(8))

number_of_days
Enter an Integer (Numeric, Signed or Packed) that specifies the number of days that $DATEPLUS adds to or $DATEMINUS subtracts from date.

You can use any expression except a call to the functions JULIAN or CHECK

Example

The following example adds five days to the specified date.

$DATEPLUS(20000328; 5) returns 20000402

The following example subtracts five days from the specified date.

$DATEMINUS(20000328; 5) returns 20000323

$JULIAN

Description

$JULIAN returns the year and the Julian day of the year for a Date expression. (1 January is equal to 1.)

Syntax

$JULIAN(date)

Return

Integer on 5 digits if the date length is 6, 6 digits if the date length is 7, 7 digits if the date length is 8

Parameters

You can use any expression that returns a value.

date
Specify the Date for which you want to know the day of the year.

The data type used for date must be either:

  • Date
  • Numeric (the length must be compatible with a date, that is N(6), N(7) or N(8))

Example

The following example uses the $JULIAN function in a mapping expression to calculate the day of the year for a given date, and converts it to an Integer. The mapped expression is written to a target field.

NOTE: If the target field is numeric and contains three characters, the result of the function is only the sequence number of the day, without the value of the year.

  • Target field: OEFIELD1
  • Mapping Rule:
    • $JULIAN(DATEIE1)
    • If the value of DATEIE1 is 20030114, representing 14 January 2003, OEFIELD1 contains 2003014 indicating the 14th day of the year 2003. Similarly, if the value of DATEIE1 is 20030714, OEFIELD1 contains 2003195.

$SYSDATE

Description

$SYSDATE returns the current date of your operating system. If you specified a date in the AccountingIntegrator Rule Engine Script file for the DATE_OPERATION parameter, the Function returns this processing date.

The target field that you define must be of the same data type as the value supplied by the $SYSDATE function. The data type used in the target field must be either:

  • Date
  • Numeric (the length must be compatible with a date, that is N(6), N(7) or N(8))

Syntax

$SYSDATE()

Return

Date (8 digits)

Parameters

None

Example

$SYSDATE() returns the current system date.

$DAY

Description

$DAY returns the day of the month, expressed as a two-digit numeric value, from an expression that specifies the date.

Syntax

$DAY(date)

Return

Integer on two digits

Parameters

date

Specify a Date

The data type used for date must be either:

  • Date
  • Numeric (the length must be compatible with a date, that is N(6), N(7) or N(8))

Only Business-Document field or Pre-Calculation with length 6, 7 or 8 are authorized.

The target field that you define must be compatible with Integer data type.

Example

The following example returns the day from the date and time expression.

$DAY(FIELD1) where FIELD1 =20040323, returns 23

$MONTH

Description

$MONTH returns the month, expressed as a two-digit numeric value, from an expression that specifies the date.

Syntax

$MONTH(date)

Return

Integer on two digits

Parameters

date
Specify a Date

The data type used for date must be either:

  • Date
  • Numeric (the length must be compatible with a date, that is N(6), N(7) or N(8))

Only Business-Document field or Pre-Calculation with length 6, 7 or 8 are authorized.

The target field that you define must be compatible with Integer data type..

Example

The following example returns the month from the date and time expression.

$MONTH(FIELD1) where FIELD1 =20040323, returns 03

$YEAR and $YEAR4

Description

$YEAR returns the year, expressed as a two-digit numeric value, from a date expression.

$YEAR4 returns the year, expressed as a four-digit numeric value from a date expression.

Syntax

$YEAR(date)

$YEAR4(date)

Return

Integer on 2 digits if $YEAR or 4 digits if $YEAR4

Parameters

date
Specify a Date

For the $YEAR function, the data type used for date must be either:

  • Date
  • Numeric (The length must be compatible with a date, that is N(6), N(7) or N(8)).

For the $YEAR function, only Business-Document field or Pre-Calculation with length 6, 7 or 8 are authorized.

For the $YEAR4 function, only Business-Document field or Pre-Calculation with length 8 are authorized.

The target field that you define must be compatible with Integer data type.

Example

The following example returns the year from the date and time expression.

$YEAR(FIELD1) where FIELD1 =20040323, returns 04

$YEAR4(FIELD1) where FIELD1 =20040323, returns 2004

$NBDAYS

Description

$NBDAYS calculates the difference between two dates (without distinguishing between business and non-working days).

$NBDAYS returns a five-digit numeric value from a date expression. The recommended target field type is N(5).

Syntax

$NBDAYS(start_date;end_date)

Return

Integer on 5 digits

Parameters

You can use any expression that returns a value with data type Date except a call to the Functions DATEPLUS or DATEMINUS.

start_date
Specify a start Date

The data type used for start_date must be :

  • Date

end_date
Specify an end Date

The data type used for end_date must be :

  • Date

Example

The following example calculates the number of days between the first date and the second date.

$NBDAYS(20000328; 20000402) returns 5

Related Links