Converts dates to storage format and vice versa.
When NLS is enabled, the locale default date format overrides any default
date format set in the msg.text file.
Syntax
D [years.digits] [delimiter skip] [separator] [format.options
[ modifiers ] ] [ E ] [ L ]
years.digits indicates the number of
digits of the year to output. The default is 4. On input years.digits is
ignored. If the input date has no year, the year is taken from the system
date.
delimiter is any single nonnumeric character
used as a field delimiter in the case where conversion must first do a group
extraction to obtain the internal date. It cannot be the system delimiter.
skip must accompany the use of delimiter and
is the number of delimited fields to skip in order to extract the date.
separator is the character used to separate the day,
month, and year on output. If you do not specify separator, the date
is converted in the form 01 DEC 1999. On input separator is ignored.
If NLS is enabled and you do not specify years.digits or separator,
the default date form is 01 DEC 1999.
format.options is
up to six options that define how the date is output (they are ignored on
input). Each format option can have an associated modifier, described below.
Format options can only be used in certain combinations as described below.
The options are as follows:
- Y [ n ] outputs the year number as n digits.
- YA outputs the name of the Chinese calendar year
only. If NLS is enabled, uses the YEARS field in the Time/Date locale.
- M outputs the month only as a number from 1 through
12.
- MA outputs only the month's name. If NLS is enabled,
uses the MONS field in the Time/Date locale. You can use any combination of
uppercase and lowercase letters for the month; IBM® InfoSphere™ DataStage® checks the combination against
the ABMONS field, otherwise the MONS field.
- MB outputs the abbreviated month name. If NLS is
enabled, uses the ABMONS field in the Time/Date locale; otherwise, uses the
first three characters of the month name.
- MR outputs the month number in Roman numerals.
- D outputs the day of the month as a number from
1 through 31.
- W outputs the day of the week as a number from 1
through 7, where Monday is 1. If NLS is enabled, uses the DAYS field in the
Time/Date locale, where Sunday is 1.
- WA outputs the day by name. If NLS is enabled, uses
the DAYS field in the Time/Date locale, unless modified by the format modifiers, f1,
f2, and so forth.
- WB outputs the abbreviated day name. If NLS is enabled,
uses the ABDAYS field in the Time/Date locale.
- Q outputs the quarter of the year as a number from
1 through 4.
- J outputs the day of the year as a number, 1 through
366.
- N outputs the year number within the current era.
If NLS is enabled, uses the ERA STARTS field in the Time/Date locale.
- NA outputs the era name corresponding to the current
year. If NLS is enabled, uses the ERA NAMES or ERA STARTS fields in the Time/Date
locale.
- Z outputs the time zone name.
The following shows which format options can be used
together:
- Use this option...
- With these options...
- Y
- M, MA, D, J, [modifiers]
- YA
- M, MA, D, [modifiers]
- M
- Y, YA, D, [modifiers]
- MA
- Y, YA, D, [modifiers]
- MB
- Y, YA, D, [modifiers]
- D
- Y, M, [modifiers]
- N
- Y, M, MA, MB, D, WA, [modifiers]
- NA
- Y, M, MA, MB, D, WA, [modifiers]
- W
- Y, YA, M, MA, D
- WA
- Y, YA, M, MA, D
- WB
- Y, YA, M, MA, D
- Q
- J
- Y, [modifiers]
- Z
- [modifiers]
[ modifiers ] modify the output formats
for the data specified by format.options. You can specify up to six
modifiers, separated by commas. The commas indicate which format.option each
modifier is associated with, therefore you must include all the commas, even
if you want to specify only one modifier (see examples). They can be any of
the following values:
- n displays n characters. It is used with
the D, M, Y, W, Q and J numeric options. It is used with MA, MB, WA, WB, YA,
N, "text" text options.
- A[n] displays the month as n alphabetic characters.
It is used with the Y, M, W, and N options.
- Z[n] suppresses leading zeros and displays as n digits.
It works as n with numeric options.
- E toggles day/month/year and month/day/year format for
dates.
- L displays month or day names as lowercase. The default
is uppercase.
Value Returned by the Status Function
If you input an invalid date to this code, it returns a valid
internal date but flags the anomaly by assigning a Status function
value of 3. For example, 02/29/99 is interpreted as 03/01/99, and 09/31/93
is interpreted as 10/01/93. If the input date is a null value, Status is
assigned a value of 3 and no conversion occurs.
Examples
The following
examples show the effect of various D conversion codes with the Iconv function:
- Conversion Expression
- Internal Value
- X = Iconv("31 DEC 1967", "D")
- X = 0
- X = Iconv("27 MAY 97", "D2")
- X = 10740
- Iconv("05/27/97", "D2/")
- X = 10740
- X = Iconv("27/05/1997", "D/E")
- X = 10740
- X = Iconv("1997 5 27", "D YMD")
- X = 10740
- X = Iconv("27 MAY 97", "D DMY[,A3,2]")
- X = 10740
- X = Iconv("5/27/97", "D/MDY[Z,Z,2]")
- X = 10740
- X = Iconv("27 MAY 1997", "D DMY[,A,]")
- X = 10740
- X = Iconv("97 05 27", "DYMD[2,2,2]")
- X = 10740
The following examples show the effect of
various D conversion codes with the Oconv function:
- Conversion Expression
- External Value
- X = Oconv(0, "D")
- X = "31 DEC 1967"
- X = Oconv(10740, "D2")
- X = "27 MAY 97"
- X = Oconv(10740, "D2/")
- X = "05/27/97"
- X = Oconv(10740, "D/E")
- X = "27/05/1997"
- X = Oconv(10740, "D-YJ")
- X = "1997-147"
- X = Oconv(10740, "D2*JY")
- X = "147*97"
- X = Oconv(10740, "D YMD")
- X = "1997 5 27"
- X = Oconv(10740, "D MY[A,2]")
- X = "MAY 97"
- X = Oconv(10740, "D DMY[,A3,2]")
- X = "27 MAY 97"
- X = Oconv(10740, "D/MDY[Z,Z,2]")
- X = "5/27/97"
- X = Oconv(10740, "D DMY[,A,]")
- X = "27 MAY 1997"
- X = Oconv(10740, "DYMD[2,2,2]")
- X = "97 05 27"
- X = Oconv(10740, "DQ")
- X = "2"
- X = Oconv(10740, "DMA")
- X = "MAY"
- X = Oconv(10740, "DW")
- X = "2"
- X = Oconv(10740, "DWA")
- X = "TUESDAY"