Legacy date functions are for use with legacy dates. For a definition of legacy dates and times, see Using Legacy Date Functions. | In this section: DAY: Extracting the Day of the Month From a Date | QUARTER: Determining the Quarter SETMDY: Setting the Value to a Date SUB: Subtracting a Value From a Date |
Available Operating Systems: All Available Languages: Maintain | How to: | Example: |
The ADD function adds a given number of days to a date.
ADD(date,value)
or
date.ADD(value)
where:
date
Is the date to add days to, or a field containing the date.
value
Is the number of days by which to increase the date.
This function changes the value of date.
ADD adds 10 days to the each value in the DateVar field:
ADD(DateVar, 10)
The following are sample values for DateVar and the corresponding values for ADD(DateVar, 10):
DateVar ADD(DateVar, 10);
------- -----------------
12/31/1999 01/10/2000
01/01/2000 01/11/2000
01/02/2000 01/12/2000
Available Operating Systems: All Available Languages: Maintain | How to: | Example: |
The DAY function extracts the day of the month from a date and returns the result as an integer.
DAY(date);
where:
date
Is the date (in date format) to extract the day of the month from, or a field containing the date.
DAY extracts the day of the month from the DATE field:
DAY(DATE)
The following are sample values for DATE and the corresponding values for DAY(DATE):
DATE DAY(DATE)
---- ---------
01/01/2000 1
01/02/2000 2
01/03/2000 3
Available Operating Systems: All Available Languages: Maintain | How to: | Example: |
The JULIAN function determines the number of days that have elapsed in the given year up to a given date, and returns the result as an integer.
JULIAN(date);
where:
date
Is the date (in date format) for which to determine the number of days elapsed in the given year, or a field containing the date.
JULIAN determines the number of days that have elapsed up to the date in the DATE field:
JULIAN(DATE)
The following are sample values for DATE and the corresponding values for JULIAN(DATE):
DATE JULIAN(DATE)
---- ------------
01/01/2000 1
02/01/2000 32
03/01/2000 61
Available Operating Systems: All Available Languages: Maintain | How to: | Example: |
The MONTH function extracts the month from a date and returns the result as an integer.
MONTH(date);
where:
date
Is the date (in date format) to extract the month from, or a field containing the date.
MONTH extracts the month from each value in the DATE field:
MONTH(DATE)
The following are sample values for DATE and the corresponding values for MONTH(DATE):
DATE MONTH(DATE)
---- -----------
01/01/2000 1
02/01/2000 2
03/01/2000 3
Available Operating Systems: All Available Languages: Maintain | How to: | Example: |
The QUARTER function determines the quarter of the year in which a date resides, and returns the result as an integer.
QUARTER(date);
where:
date
Is the date (in date format) to determine the quarter for, or a field containing the date.
QUARTER extracts the quarter component from each value in the DATE field:
QUARTER(DATE)
The following are sample values for DATE and the corresponding values for QUARTER(DATE):
DATE QUARTER(DATE)
---- -------------
01/01/2000 1
04/01/2000 2
07/01/2000 3
Available Operating Systems: All Available Languages: Maintain | How to: | Example: |
The SETMDY function sets a value to a date based on numeric values representing a day, month, and year. SETMDY returns a 0 if the function is successful, and a negative number if the function fails.
SETMDY(date, month, day, year);
or
date.SETMDY(month, day, year);
where:
date
Is the date, in date format, or a field containing the date.
month
Is an integer value representing a month.
day
Is an integer value representing the day of the month.
year
Is an integer value representing a year.
SETMDY sets the value of DateVar, which is formatted as a date that displays as wrMtrDYY (for example, Saturday, January 1, 2000):
SETMDY(DateVar, month, day, year);
The following are sample values for month, day, and year, and the corresponding dates for DateVar:
month day year DateVar
----- --- ---- -------
04 05 1965 Monday, April 5, 1965
02 01 1997 Saturday, February 1, 1997
01 01 2000 Saturday, January 1, 2000
Available Operating Systems: All Available Languages: Maintain | How to: | Example: |
The SUB function subtracts a given number of days from a date.
SUB(date,value)
or
date.SUB(value)
where:
date
Is the date to subtract the value from, or a field containing the date.
value
Is the value to subtract from the date.
SUB subtracts 10 days from each value in the DateVar field.
SUB(DateVar, 10)
The following are sample values for DateVar and the corresponding values for
SUB(DateVar, 10):
DateVar SUB(DateVar, 10);
------- -----------------
12/31/1999 12/21/2000
01/01/2000 12/22/2000
01/02/2000 12/23/2000
Available Operating Systems: All Available Languages: Maintain | How to: | Example: |
The WEEKDAY function determines the day of the week for a date and returns the result as an integer (1=Monday, 2=Tuesday, and so on).
WEEKDAY(date);
where:
date
Is the date (in date format) to determine the weekday for, or a field containing the date.
WEEKDAY determines the day of the week for each date in the DATE field, and stores that day as a number corresponding to a weekday:
WEEKDAY(DATE)
The following are sample values for DATE and the corresponding values for WEEKDAY(DATE)
DATE WEEKDAY(DATE)
---- -------------
01/01/2000 6
01/02/2000 7
01/03/2000 1
Available Operating Systems: All Available Languages: Maintain | How to: | Example: |
The YEAR function extracts the year from a date.
YEAR(date);
where:
date
Is the date to extract the year from, or a field containing the date.
YEAR extracts the year from the DATE field, and stores that year in the YEAR(DATE) field:
YEAR(DATE)
The following are sample values for DATE and the corresponding values for YEAR(DATE):
DATE YEAR(DATE)
---- ----------
01/01/2000 2000
02/01/2001 2001
03/01/2002 2002