The DAYS
function returns the number of days from 0000-03-01 to the specified date.
The DAYS
function also accepts Julian dates with 2 or 4-digit year (for example, yyddd
or yyyyddd
), and year-month-day dates with 2-digit year such as yymmdd
.
Category
Date / Time
Syntax
DAYS(date)
Parameter and Description
Parameter | Description |
---|---|
date | This parameter specifies a source date in yyyymmdd or yyyy-mm-dd format. |
Tip: A script would normally specify the name of a variable or a record field containing a date as the argument to the
DAYS
function, but you can supply a literal.Example 1
Function | Return Value |
---|---|
DAYS('00000301') |
0 |
DAYS('0000-03-02') |
1 |
DAYS(2024-06-03) |
739345 |
Note: When a literal date is supplied, the single quotes (' ') are required. You do not specify quotes when the argument is a variable or field name.
Example 2 - sample code snippet using variables
Calculate the number of days between two dates.
DECLARE DATE1 10 '2024-06-03';
DECLARE DATE2 10 '2024-05-31';
DECLARE ELAPSED_DAYS 10 '';
ELAPSED_DAYS =DAYS(DATE1) - DAYS(DATE2)
OUTMSG(0, 'Elapsed days from ',DATE2,' to ',DATE1,' is ',ELAPSED_DAYS)