Dates [ HP ALLBASE/BRW Reference Manual ] MPE/iX 5.0 Documentation
HP ALLBASE/BRW Reference Manual
Dates
You can manipulate dates using HP ALLBASE/BRW Date types. Items of type
Date are defined in the data dictionary. (See Chapter 18 for the
data dictionary definitions of Date types.) Internally, a date always
consists of a month, a day, and a 4-digit year (1992, not 92). However,
Date items can be output in different ways, depending on the edit-mask
(for output) and the data dictionary definition (for input). HP
ALLBASE/BRW converts all dates to the form YYYYMMDD and handles them
internally in this form. Date types require single quotes and use the
following conventions, assuming the input format is month-day-year:
-------------------------------------------------------------------------------------------
| |
| '4/16/1992' <<April 16, 1992>> |
| |
| '4.16.1992' <<same>> |
| |
| '8/24/91' <<year is 1991>> |
| |
| '10/18/03' <<year is 1903>> |
| |
| '12/6' <<year is current year>> |
| |
| '12/91' <<invalid>> |
| |
-------------------------------------------------------------------------------------------
Date input format is defined in BRWSETUP. The alternative formats are
day-month-year or year-month-day. See also the "Dates" section of this
chapter.
Date Extraction Functions
Date extraction functions extract parts of a date value, as shown in
these examples,
------------------------------------------------------------------------------------------
| |
| Function Date Value Result |
| |
------------------------------------------------------------------------------------------
| |
| DAY_OF_WEEK ('9/28/1992') <<6>> (<term noglossWhere 1 = |
| Monday,..... |
| 7 = Sunday|) |
| |
| DAY_OF_MONTH ('9/28/1992') <<28>> |
| |
| DAY_OF_YEAR ('9/28/1992') <<271>> |
| |
| WEEK_OF ('9/28/1992') <<39>> |
| |
| MONTH_OF ('9/28/1992') <<9>> |
| |
| YEAR_OF ('9/28/1992') <<1992>> |
| |
| (result is always 4-digit year> |
| |
------------------------------------------------------------------------------------------
NOTE The default for the day of the week is that the first day of the
week is MONDAY, not SUNDAY.
The result of a date extraction function is an integer-type item.
Date Duration Functions
Date duration functions calculate the difference between two date values
as positive numbers. Date duration is specified as shown here:
DAYS_DIFF (date1, date2)
WEEKS_DIFF (date1, date2)
MONTHS_DIFF (date1, date2)
YEARS_DIFF (date1, date2)
The result of a date duration function is an integer-type item.
The date duration functions calculate:
WEEKS_DIFF as DAYS_DIFF / 7
MONTHS_DIFF as DAYS_DIFF / 30.4385
YEARS_DIFF as DAYS_DIFF / 365.2422
and round the result to the nearest integer number.
Date Addition Functions
Date addition functions calculate a date value by adding days, weeks,
months or years to a date value, as shown here:
ADD_DAYS (date, days)
ADD_WEEKS (date, weeks)
ADD_MONTHS (date, months)
ADD_YEARS (date, years)
The result of a date addition function is a date-type item.
NOTE Out-of-range dates are corrected automatically, for example:
ADD_MONTHS (1/31/1992,1) 2/28/1992
Date Subtraction Functions
Date subtraction functions calculate a date value by subtracting days,
weeks, months or years from a date value, as shown here:
SUB_DAYS (date, days)
SUB_WEEKS (date, weeks)
SUB_MONTHS (date, months)
SUB_YEARS (date, years)
The result of a date subtraction function is a date-type item.
Date Operations
HP ALLBASE/BRW supplies many standard functions to manipulate dates.
See the "Standard Functions" section of this chapter for a complete list.
MPE/iX 5.0 Documentation