Was this helpful?
Date Format D
You can output date expressions using a D format specification. The date format specification is a D or d, followed by a quoted string template indicating exactly how a specific date would be printed. Ingres requires that you delimit the template with single (') or double (") quotation marks; single quotes are recommended for consistency with requirements for quoting string constants.
The date is left justified by default, but by specifying the optional plus sign (+), you can right justify the date. The template must be surrounded with single quotes.
The syntax of a date template is:
[-|*|+] D|d 'template'
where:
'template'
Specifies a string of characters representing a sample absolute date and time
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:
d'3/1901'
The following examples demonstrate the use of absolute date and time templates:
Format
Value
Output
d' 2/ 3/01'
25-oct-1998
10/25/98
d' 2/ 3/01'
5-jun-1909
6/ 5/09
d'03-02-01'
5-oct-1998 07:24:12
05-10-98
d'2/3/1'
25-oct-1998
10/25/98
d'2/3/1'
5-jun-1909
6/5/9
d'010203'
5-oct-1998
981005
d'1\|2\|3'
5-oct-1998
98|10|5
d'FEBRUARY, 1901'
1-sep-2134 09:13:02
SEPTEMBER 2134
d'FEBRUARY, 1901'
7-may-1962 13:08:42
MAY, 1962
d'Sunday'
5-oct-1998
Wednesday
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'3/01'
5-oct-1998
278/98
d'February 3rd'
29-jul-1954
July 29th
d'3rd day of 1901'
11-may-1999
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.
Date and Time Interval Templates
Date and time interval templates show the amount of elapsed time between two dates or times, rather than an absolute date or time.
Specify a time interval with a quoted string containing one of many possible representations of a sample time interval, such as 1 year or 1 yr 3 day. The selection and arrangement of the time interval elements within the template indicate the way you want time intervals to be displayed or printed.
Use the following time interval as the basis for your template:
1 year 2 months 3 days 4 hours 5 minutes 6 seconds
You can use all or only some of these units in your template, and the units can be arranged in any order. Use the plural or singular form of any unit, as well as the singular or plural form of the abbreviations, yr and mo, hr, min, and sec.
To specify a time interval, use the format d'template', where template contains one or more time interval keywords (for example, minutes) preceded by the appropriate digit from the representative time interval string, as in:
d'5 minutes'
This format displays results followed by the keyword; for example:
9 minutes
The following examples demonstrate the use of the time interval templates:
Format
Value
Output
D'1 year'
3 yrs 5 mos 16 days
3 years
d'2 MONTHS, 3 DAYS'
3 yrs 5 mos 1 days
41 MONTHS, 1 DAY
d'1 yr 3 day'
1 yrs 5 mos 16 days
1 yr 168 days
D'4 hours 6 seconds'
23 hrs 8 mins 53 secs
23 hours 533 seconds
d'04:05 \hours'
23 hrs 0 mins 53 secs
23:01 hours
d'3 days 4 hours'
23 hrs 8 mins 53 secs
0 days 23 hours
d' 1 yr 2 mos 3 days'
200 yrs 11 mos 28 days
200 yr 11 mos 28 days
d' 1 yr 2 mos 3 days'
5 yrs 1 mos 3 days
5 yr 1 mos 3 days
For the purpose of date interval calculation, Report-Writer assumes there are 30.4376875 days in a month and 365.2425 days in a year. The smallest unit is rounded up.
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. Report-Writer 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 last two examples in the preceding examples of output).
For English-language releases, if the number preceding a completely spelled template word is 1, Report-Writer prints the template word in its singular form (for example, 1 year); otherwise, it prints the word in its plural form (for example, 2 years). Report-Writer makes this adjustment only if you spell out the template word completely. For example, specifying 2 month would produce appropriate singular and plural results, such as 1 month, 5 months, and 9 months. Specifying 2 mo would produce only singular results such as 1 mo, 5 mo, or 9 mo.
Report-Writer prints any character preceded by a backslash (\) exactly as it appears.
Last modified date: 08/28/2024