11. Report-Writer Expressions and Formats : Format Specifications : Date Format D : Absolute Date and Time Templates
Share this page                  
Absolute Date and Time Templates
Specify the absolute date and time format by a string containing one of many possible representations of a sample date and time, such as "SUN Feb 3 04:05:06 p.m." or "FEB 03 16:05." The selection and arrangement of the sample date and time elements within the template indicate the way you want all dates and times to be displayed or printed.
The following date and time must be used as the basis for your template:
Sunday, 1901 February 3 at 4:05:06 p.m.
Note:  This specific date and time was chosen as the sample for the template because Sunday is the first day of the week, and arguments 1, 2, 3, 4, 5, and 6 are the year, month, day, hour, minute, and second, respectively. This makes it easy to interpret the elements of the template correctly. For instance, in the template '2/3/01,' the 2 indicates the month (February), the 3 indicates the day (3), and 01 indicates the year (1901).
Your template can contain only the weekday of Sunday and the month name of February (or their accepted abbreviations), the day of the month as 3, the year 1901, the time 04:05:06 p.m. in various formats, and the time designation p or p.m. (including the periods for p.m.). Report-Writer prints any other word exactly as entered.
You can specify 24-hour (military) time by using 16 instead of 4 for the hour in your template. Do not use p or p.m. with 24‑hour time.
You can use all or only some of the arguments in your template, and you can arrange the arguments in any order. You can use any combination of lowercase and uppercase letters, and you can abbreviate the day of the week as Sun or Su and the month as Feb or Fe. The resulting output assumes the same format as your template.
You can create ordinal numbers from numbers by suffixing them with the appropriate "st", "nd", "rd", or "th," as in:
d'3rd day of the 2nd month of 1901'
To print the day of the year, you specify the day and year, but leave out the month:
The following examples demonstrate the use of absolute date and time templates:
d' 2/ 3/01'
d' 2/ 3/01'
6/ 5/09
5-oct-1998 07:24:12
d'FEBRUARY, 1901'
1-sep-2134 09:13:02
d'FEBRUARY, 1901'
7-may-1962 13:08:42
MAY, 1962
d'SUN Feb 3 16:05 1901'
13-oct-1998 07:24:03
THU Oct 13 07:24 1998
d'FEB 03 4:05:06 p.m.'
12-dec-1998 22:13:03
DEC 12 10:13:03 p.m.
d'04:05:06 PM'
5-oct-1998 14:08:45
02:08:45 PM
d'04:05:06 PM'
5-oct-1998 07:29:12
07:29:12 AM
d'16:05 pst'
5-oct-1998 14:08:45
14:08 pst
d'February 3rd'
July 29th
d'3rd day of 1901'
131st day of 1999
If you use the special report variables, current_date, current_day, or current_time, to print an absolute date, day, or date and time, be sure to use only that portion of the date template that matches the returned variable value. Specifying more of the template than you need causes Report-Writer to print zeros (0) or empty strings for the unneeded portions of the template. For example, suppose you specify the following:
.print current_date(d' FEB 03 1901 16:05:06')
Report-Writer returns the current date, but with a time of 00:00:00, because the current_date report variable returns only the date and not the time.
Numbers requiring more than one digit replace preceding blanks or zeroes in the template, as needed. If there are no more available preceding blanks or zeroes, the number expands to the right. Ingres retains in the output any single blank following a letter, word, or number in the template; it does not replace such a blank with a succeeding number.
You can align columns of numbers by preceding them with an appropriate number of blanks or zeroes (as shown by the first three examples in the preceding examples of output).
Because full month and weekday names (as well as numbers without preceding blanks or zeros) are of differing lengths, date columns using either of these components in the format rarely line up.
Following February or Sunday with a vertical bar (|) specifies that for shorter month names or weekdays, an appropriate number of blanks are substituted for the vertical bar to line up the components. Similarly, if you place a vertical bar after a single digit number in your template, Report-Writer prints a blank before each single-digit number it encounters (unless the digit is already preceded by a blank or zero).
For example, the template Sunday,| February | 3,| 1901 produces dates like:
Friday,    January  15, 1998
Wednesday, May       4, 1998
Saturday,  November 20, 1998
Report-Writer prints any character preceded by a backslash exactly as it appears.