Template:Datetime and format examples

From m204wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
YYMMDD This is the common six-digit date format which supports sort order if all dates are within a single century.

The following SOUL code fragment prints the value OK:

If $sir_date2nd('960229', 'YYMMDD') > -9E12 Then Print 'OK' End If

For Sir2000 User Language Tools users, the following statement prints the value 1:

print $sir_datechk('YYMMDD', '960229')

YYYYMMDD This is the common eight-digit date format which supports sort order with dates in two centuries.

The following SOUL code fragment prints the value 19921212.

%n = $sir_date2nd('921212', 'YYMMDD') Print $sir_nd2date(%n, 'YYYYMMDD')

For Sir2000 User Language Tools users, the following statement prints the value 19921212:

print $sir_datecnv('YYMMDD', 'YYYYMMDD', '921212')

MM/DD/YY This is the U.S. six-digit date format for display. The value 12/14/97 matches this format.

The following SOUL code fragment prints the value OK:

If $sir_date2nd('12/14/94', 'MM/DD/YY') > -9E12 Then Print 'OK' End If

For Sir2000 User Language Tools users, the following statement prints the value 1:

print $sir_datechk('MM/DD/YY', '12/14/94')

Note: With non-strict format matching, such as $Sir_Date2nd, the leading zero corresponding to an MM token may be given as a blank, thus allowing " 7/15/98".

With strict matching, however, such a leading blank is not allowed for MM. A leading blank month value with a strict $function (that is, one of the Sir2000 User Language Tools $functions) requires the BM token.

If the data contains leading zeroes in some month instances and leading blanks in others, you must use a non-strict $function.

DD.MM.YY This is a European six-digit date format for display. The value 14.12.97 matches this format.

The following SOUL code fragment prints the value OK:

If $sir_date2nd('14.12.94', 'DD.MM.YY') > -9E12 Then Print 'OK' End If

For Sir2000 User Language Tools users, the following statement prints the value 1:

print $sir_datechk('DD.MM.YY', '14.12.94')

Note: With non-strict format matching, such as $Sir_Date2nd, the leading zero corresponding to a DD token may be given as a blank, thus allowing " 1.01.00".

With strict matching, however, such a leading blank is not allowed for DD. A leading blank day value with a strict $function (that is, one of the Sir2000 User Language Tools Functions) requires the BD token.

If the data contains leading zero days in some instances and leading blanks in others, you must use a non-strict $function.

Wkday, DAY Month YYYY "A"T HH:MI This is a format that could be used for report headers.

The following SOUL statement prints a value like Friday, 7 February 1998 AT 21:33:

print $sir_date('Wkday, DAY Month YYYY "A"T HH:MI')

Note:

  • If an input format contains AM or PM, then the time (HH:MI) must be between 00:01 and 12:00, and it must be accompanied by either AM or PM.
  • If an input format contains DAY (for example, DAY MON YY) with non-strict format matching, such as $Sir_Date2nd, the string matching it may have a leading zero, thus allowing 06 MAY 98.

    With strict matching $functions (that is, one of the Sir2000 User Language Tools $functions) however, such a leading zero is not allowed for DAY; a single digit must be supplied for days 1 through 9.

  • If an input format contains HH with non-strict format matching, such as $Sir_Date2nd, the string that matches it may have a leading blank, thus allowing " 8:30".

    With strict matching, however, such a leading blank is not allowed for HH; a leading blank hour value with a strict $function requires the BH token.

    If the data contains leading zero hours in some instances and leading blanks in others, you must use a non-strict $function.

YYIIII This format might be used for data that contains a two-digit year prefixing other information, such as a sequence number. The value 92A123 matches this format.

The following SOUL code fragment prints the value 02:

%d = $sir_date2nd('92ABCD', 'YYIIII') Print $sir_nd2date(%d + 10*365.25, 'YY')

For Sir2000 User Language Tools users, the following statement prints the value 1992ABCD:

print $sir_datecnv('YYIIII', 'YYYYIIII', '92ABCD')

Note: When a pair of format strings are used for transforming date values, for example for $Sir_DateCnv or processing of updates to SIRFIELD RELATE fields, both formats must have the same number of I tokens. The $functions with both an input and output format, for example $Sir_DateCnv, are only available in the Sir2000 User Language Tools; SIRFIELD is part of the Sir2000 Field Migration Facility.

YY* This format might be used for data that contains a two-digit year prefixing other information, such as a sequence number, when the other information is variable length. The values 92 and 92ABC123 match this format.

The following SOUL code fragment prints the values OK and OK:

If $sir_date2nd('92', 'YY*') > -9E12 Then Print 'OK' End If IF $sir_date2nd('1992ABC', 'YYYY*') > -9E12 THEN Print 'OK' End If

For Sir2000 User Language Tools users, the following statements print the values 1992 and 1992XYZ:

print $sir_datecnv('YY*', 'YYYY*', '92') print $sir_datecnv('YY*', 'YYYY*', '92XYZ')

Note:

  • At most one occurrence of the asterisk (*) token may appear in a datetime format.
  • If a pair of format strings are used for transforming date values, for example for $Sir_DateCnv or processing of updates to SIRFIELD RELATE fields, then if a * token appears in one of the formats, a * must also appear in the other format.

    The $functions with both an input and output format, for example $Sir_DateCnv, are only available in the Sir2000 User Language Tools; SIRFIELD is part of the Sir2000 Field Migration Facility.

CYYDDD This is a compact six-digit date format with explicit century information, from 1900 through and including 2899. The value 097031 (representing 31 January 1997) matches this format.

The following SOUL fragment prints the value OK:

If $sir_date2nd('097031', 'CYYDDD') > -9E12 Then Print 'OK' End If

For Sir2000 User Language Tools users, the following statement prints the value 1:

print $sir_datechk('CYYDDD', '097031')

ZYYMMDD This is a compact six- or seven-digit date format with explicit century information, from 1900 through and including 2899, that can often be used with "old" YYMMDD date values in the 1900s. The values 970501 (representing 1 May 1997) and 1000501 (representing 1 May 2000) match this format.

The following SOUL fragment prints the values OK and OK:

* Check 1 Dec, 1997: If $sir_date2nd('971201', 'ZYYMMDD') > -9E12 Then Print 'OK' End If * Check 1 Dec, 2000: If $sir_date2nd('1001201', 'ZYYMMDD') > -9E12 Then Print 'OK' End If

For Sir2000 User Language Tools users, the following statements print the values 1 and 1:

* Check 1 Dec, 1997: print $sir_datechk('ZYYMMDD', '971201') * Check 1 Dec, 2000: print $sir_datechk('ZYYMMDD', '1001201')

Note: With non-strict format matching (such as $Sir_Date2nd), a three-digit number with a leading zero may correspond to a ZYY token, thus allowing "0971201".

With strict matching, however, a three-digit value with a leading zero is not allowed for ZYY. A three-digit value less than 100 with a strict $function (that is, one of the Sir2000 User Language Tools Functions) requires the CYY token.

If the data contains values less than 100 as three digits in some instances and as two digits in others, you must use a non-strict $function.

YY0000 Decimal digits can be used as separator characters. The value 980000 matches this format.

The following SOUL fragment prints the value 1992NA:

%n = $sir_date2nd('92000', 'YY000') Print $sir_nd2date(%n, 'YYYY"N"A')

For Sir2000 User Language Tools users, the following SOUL statement prints the value 1992NA:

Print $sir_datecnv('YY0000', 'YYYY"N"A', '920000')

Note: Numeric separators, unlike alphabetic separators, do not need to be preceded by a double-quote character (").