Maintain-specific Standard Date and Time Functions
Standard date and time functions are for use with non-legacy dates. For a definition of standard dates and times, see Date-Time Functions.
HHMMSS: Retrieving the Current Time (Maintain)
The HHMMSS function retrieves the current time from the operating system as an 8-character string, separating the hours, minutes, and seconds with periods.
To use this function, you must import the function library MNTUWS. For information on importing a function library, see Calling a Function.
There is also an HHMMSS function available in the reporting language. For information on this function, see HHMMSS: Retrieving the Current Time.
Retrieve the Current Time
HHMMSS()
Retrieving the Current Time
HHMMSS retrieves the current time from the operating system:
MAINTAIN Module Import (mntuws); Case Top Compute now/a10 = hhmmss(); type "Now = <<now" EndCase END
The output is:
Now = 14.25.33
Initial_HHMMSS: Returning the Time the Application Was Started
The Initial_HHMMSS function returns the time when the Maintain Data application was started as an 8-character string, with embedded periods separating the hours, minutes, and seconds.
To use this function, you must import the function library MNTUWS. For details on importing this library, see Calling a Function.
Retrieve the Initial Time
Initial_HHMMSS()
Initial_TODAY: Returning the Date the Application Was Started
The Initial_TODAY function returns the date in MM/DD/YY format when the Maintain Data application was started as an 8-character string with embedded slashes.
To use this function, you must import the function library MNTUWS. For details on importing this library, see Calling a Function.
Retrieve the Initial Date
TODAY: Retrieving the Current Date (Maintain)
The TODAY function retrieves the current date from the system in the format MM/DD/YY. TODAY always returns a date that is current. Therefore, if you are running an application late at night, use TODAY. You can remove the embedded slashes using the EDIT function.
To use this function, you must import the function library MNTUWS. For information on importing this library, see Calling a Function.
There is a version of the TODAY function that is available only in the reporting language. For information on this function, see HTMTOTS or TIMETOTS: Converting a Time to a Timestamp.
Retrieve the Current Date
TODAY()
Retrieving the Current Date
TODAY retrieves the current date from the system:
MAINTAIN Module Import (mntuws); Case Top Compute date1/a8 = today(); type "Date1 = <<date1" Endcase END
The result is:
Date1 = 07/17/02
TODAY2: Returning the Current Date
The TODAY2 function retrieves the current date from the operating system in the format MM/DD/YYYY. Use format A10 with the TODAY2 function to ensure proper results.
To use this function, you must import the function library MNTUWS. For information on importing this library, see Calling a Function.
Retrieve the Current Date
TODAY2()
Retrieving the Current Date
TODAY2 retrieves the current date from the system:
MAINTAIN Module Import (mntuws); Case Top Compute date2/a10 = today2(); type "Date2 = <<date2" Endcase END
The result is:
Date2 = 07/17/2002
ADD: Adding Days to a Date
The ADD function adds a given number of days to a date.
Add Days to a Date
ADD(date,value)
date.ADD(value)
where:
This function changes the value of date.
Adding Days to a Date
ADD adds 10 days to 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
DAY: 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.
Extract the Day of the Month From a Date
DAY(date);
where:
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
JULIAN: 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.
Determine How Many Days Have Elapsed in the Year
JULIAN(date);
where:
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
MONTH: Extracting the Month From a Date
The MONTH function extracts the month from a date and returns the result as an integer.
Extract the Month From a Date
MONTH(date);
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
QUARTER: Determining the Quarter
The QUARTER function determines the quarter of the year in which a date resides, and returns the result as an integer.
Determine the Quarter for a Date
QUARTER(date);
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
SETMDY: Setting the 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.
Set a Value to a Date
SETMDY(date, month, day, year);
date.SETMDY(month, day, year);
where:
Setting a Value to a Date
SETMDY sets the value of DateVar, which is formatted as a date that appears 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
SUB: Subtracting a Value From a Date
The SUB function subtracts a given number of days from a date.
Subtract a Value From a Date
SUB(date,value)
date.SUB(value)
where:
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
WEEKDAY: 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).
Determine the Day of the Week for a Date
WEEKDAY(date);
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
YEAR: Extracting the Year From a Date
The YEAR function extracts the year from a date.