11. Report-Writer Expressions and Formats : Format Specifications : Date Format D : Date and Time Interval Templates
 
Share this page                  
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.