Maintain-specific Legacy Date Functions

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:

ADD: Adding Days to a Date

DAY: Extracting the Day of the Month From a Date

JULIAN: Determining How Many Days Have Elapsed in the Year

MONTH: Extracting the Month From a Date

QUARTER: Determining the Quarter

SETMDY: Setting the Value to a Date

SUB: Subtracting a Value From a Date

WEEKDAY: Determining the Day of the Week for a Date

YEAR: Extracting the Year From a Date


Top of page

ADD: Adding Days to a Date

Available Operating Systems: All

Available Languages: Maintain

How to:

Add Days to a Date

Example:

Adding Days to a Date

The ADD function adds a given number of days to a date.


Top of page

Syntax: How to Add 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.


Top of page

Example: Adding Days to a 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

Top of page

DAY: Extracting the Day of the Month From a Date

Available Operating Systems: All

Available Languages: Maintain

How to:

Extract the Day of the Month From a Date

Example:

Extracting the Day of the Month From a Date

The DAY function extracts the day of the month from a date and returns the result as an integer.


Top of page

Syntax: How to Extract the Day of the Month From a Date

DAY(date);   

where:

date

Is the date (in date format) to extract the day of the month from, or a field containing the date.


Top of page

Example: Extracting the Day of the Month From a 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

Top of page

JULIAN: Determining How Many Days Have Elapsed in the Year

Available Operating Systems: All

Available Languages: Maintain

How to:

Determine How Many Days Have Elapsed in the Year

Example:

Determining How Many Days Have Elapsed in the Year

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.


Top of page

Syntax: How to Determine How Many Days Have Elapsed in the Year

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.


Top of page

Example: Determining How Many Days Have Elapsed in the Year

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

Top of page

MONTH: Extracting the Month From a Date

Available Operating Systems: All

Available Languages: Maintain

How to:

Extract the Month From a Date

Example:

Extracting the Month From a Date

The MONTH function extracts the month from a date and returns the result as an integer.


Top of page

Syntax: How to Extract the Month From a Date

MONTH(date);

where:

date

Is the date (in date format) to extract the month from, or a field containing the date.


Top of page

Example: Extracting the Month From a 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

Top of page

QUARTER: Determining the Quarter

Available Operating Systems: All

Available Languages: Maintain

How to:

Determine the Quarter for a Date

Example:

Determining the Quarter for a Date

The QUARTER function determines the quarter of the year in which a date resides, and returns the result as an integer.


Top of page

Syntax: How to Determine the Quarter for a Date

QUARTER(date);

where:

date

Is the date (in date format) to determine the quarter for, or a field containing the date.


Top of page

Example: Determining the Quarter for a 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

Top of page

SETMDY: Setting the Value to a Date

Available Operating Systems: All

Available Languages: Maintain

How to:

Set a Value to a Date

Example:

Setting a Value to a Date

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.


Top of page

Syntax: How to Set a Value to a Date

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.


Top of page

Example: Setting a Value to a Date

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

Top of page

SUB: Subtracting a Value From a Date

Available Operating Systems: All

Available Languages: Maintain

How to:

Subtract a Value From a Date

Example:

Subtracting Days From a Date

The SUB function subtracts a given number of days from a date.


Top of page

Syntax: How to Subtract a Value 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.


Top of page

Example: Subtracting Days From a 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

Top of page

WEEKDAY: Determining the Day of the Week for a Date

Available Operating Systems: All

Available Languages: Maintain

How to:

Determine the Day of the Week for a Date

Example:

Determining the Day of the Week for a Date

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).


Top of page

Syntax: How to Determine the Day of the Week for a Date

WEEKDAY(date);

where:

date

Is the date (in date format) to determine the weekday for, or a field containing the date.


Top of page

Example: Determining the Day of the Week for a 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

Top of page

YEAR: Extracting the Year From a Date

Available Operating Systems: All

Available Languages: Maintain

How to:

Extract the Year From a Date

Example:

Extracting a Year From a Date

The YEAR function extracts the year from a date.


Top of page

Syntax: How to Extract the Year From a Date

YEAR(date);

where:

date

Is the date to extract the year from, or a field containing the date.


Top of page

Example: Extracting a Year From a 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