Column 10 contains a Julian date in the form ddd-yyyy, column 20 contains a Gregorian date in the form X’0yyddmms’ and the difference in days is desired.
Example 2
Column 10 contains a Gregorian date in the form yymmdd and column 20 contains a year/month date in the form yy/mm. The difference in months is desired, although it is not known which the earlier date is (a negative result would indicate that it was datefield1). The result will be in a 5-byte field with a leading sign, using the M12 editing mask.
Example 3
The number of days from the current date until June 8th, 2013 is needed.
For the following date arithmetic functions, the eligible p,l,f fields are the full-date fields from the table Data Conversion Table – Full-Date Formats.
This is an alternate usage of DATEDIFF for full-date fields only. This alternate usage produces the difference between the two dates in days only, and the output is a printable field rather than a numerical value. The output field is 8 bytes, where the first byte is a + or - sign byte, followed by 7 digits. The sign byte will be + if the first field is greater than or equal to the second field, otherwise the byte will be - . A parsed field can be used for p1,l1 but not for p2,l2.
These date functions are used to add or subtract any of days, months, or years from the input field to create a formatted output date field.
When the unit is months or years, a valid output date will always be created. For example, subtracting one month from a March 30th date will result in February 28th in a non-leap year and February 29th in a leap year.
The numeric_field can be a number (+n or -n) or a numeric field (p,l,f) in the record, where f can be BI, FI, ZD, PD, FS, UFF, or SFF with a valid length for those formats. The value of the numeric_field must be from -3652058 to +3652058 for ADDDAYS or SUBDAYS, from -119987 to +119987 for ADDMONS or SUBMONS, or from -9998 to +9998 for ADDYEARS or SUBYEARS.
The output field is formatted by either the TOJUL or TOGREG parameter as described in Julian date Output Formats.
These date functions are used to compute new calendar dates based on a full-date input field. The input p,l can also be a parsed field.
The NEXTDday function computes the next specified weekday date relative to the input date. ''day'' in the keyword can be any of SUN, MON, TUE, WED, THU, FRI or SAT, such as NEXTDSAT.
The PREVDday function computes the previous specified weekday date relative to the input date. See above for valid ''day'' values.
LASTDAYW computes the Friday date of the week of the input date, where Friday is considered the last day of the week.
LASTDAYM computes the last date of the month of the input date.
LASTDAYQ computes the last date of the quarter of the input date.
LASTDAYY computes the last date of the year of the input date.
The output field is formatted by either the TOJUL or TOGREG parameter as described in Julian date Output Formats.