18. Working with Data Types and Data Display Formats : Date and Time Templates : Time Interval Templates
 
Share this page                  
Time Interval Templates
Time interval templates show the amount of elapsed time rather than an absolute date or time.
Note:  You cannot use input masking with time interval templates.
As in the absolute date format, you 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. You must use the following representative 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 arrange them in any order. You can use the plural or singular form of any unit, as well as the singular or plural form of the abbreviations, yr, mo, hr, min, and sec.
To specify a time interval, use the 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
Format
Example Data
Report Output
d'1 year'
3 years 5 mos
16 days
3 years
d'2 MONTHS,
3 DAYS'
3 years 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 yrs 11 mos
28 days
d' 1 yr 2 mos 3 days'
5 yrs 1 mos
3 days
5 yrs 1 mo 3 days
There are 30.4376875 days in a month and 365.2425 days in a year. When calculating a date interval, the smallest unit of time is rounded up.
Numbers requiring more than one digit use up preceding blanks or zeroes. If there are no preceding blanks or zeroes to the left, the number expands to the right. A succeeding number does not use up a single blank immediately following a letter, word, or number. You can line up columns of numbers by preceding them with an appropriate number of blanks or zeroes (note the last two examples).
The word immediately following a number is made singular if the number is one, or plural if the number is zero or greater than one. You can prevent this by preceding the word with a backslash (\). Any character preceded by a backslash is printed as you enter it.