Convert Date and Time Format (QWCCVTDT) API


  Required Parameter Group:


  Optional Parameter Group 1:


  Optional Parameter Group 2:


  Default Public Authority: *USE

  Threadsafe: Yes

The Convert Date and Time Format (QWCCVTDT) API converts date and time values from one format to another format. The QWCCVTDT API lets you:

For additional information on converting dates and times, see Usage Notes.


Authorities and Locks

None.


Required Parameter Group

Input format
INPUT; CHAR(10)

The format of the data you give QWCCVTDT to convert. Valid values are:

Input variable
INPUT; CHAR(*)

The data to be converted. If the input format is *CURRENT, then this parameter is not used. See Input and Output Variable Formats to determine the structure of the input variable for all other input formats.

Output format
INPUT; CHAR(10)

The format to convert the data to. Valid values are:


Output variable
OUTPUT; CHAR(*)

The converted data. If the output format is *DOS, the first 11 characters of this parameter are used. For details, see DOSGetDateTime Value Structure. See Input and Output Variable Formats to determine the structure of the output variable for all other output formats.

Error code
I/O; CHAR(*)

The structure in which to return error information. For the format of the structure, see Error code parameter.


Optional Parameter Group 1

Input time zone
INPUT; CHAR(10)

Specifies the time zone associated with the input variable. If the input format is *CURRENT, then this parameter is not used. The default value is *SYS. Valid values are:

Output time zone
INPUT; CHAR(10)

Specifies the time zone associated with the output variable. The default value is *SYS. Valid values are:

Time zone information
OUTPUT; CHAR(*)

Specifies the time zone information associated with the output time zone. If 0 is specified for the length of time zone information, then this parameter is not used. For the format of the structure, see Time Zone Information Value Structure.

Length of time zone information
INPUT; BIN(4)

Specifies the length of the time zone information to be returned. The minimum length is 0 which indicates to not return any time zone information.

Precision indicator
INPUT; CHAR(1)

Specifies the precision of the input and output variables. The default value is 0 or milliseconds. Valid values are:


Optional Parameter Group 2

Input time indicator
INPUT; CHAR(1)

Specifies which segment of time to use when the input variable has a date and time value that matches a repeated time. Otherwise, this parameter is not used. Repeated times occur when time changes from Daylight Saving Time (DST) to Standard Time (ST). For example, if DST ends on a given day at 02:00AM, then the segment of time from 01:00:00.000000 to 01:59:59.999999 on that day repeats. The first segment of time is considered in DST and the second segment is considered in ST. The default value is 1 or use the DST segment. For additional information on this parameter, see Usage Notes.


Input and Output Variable Formats

This table shows the format used for the input or output variable parameters.



16-Byte Character Date and Time Value Structure

This table shows the structure used for the input and output variables when the format is *JOB, *SYSVAL, *YMD, *MDY, *DMY, and *JUL and the precision indicator specifies milliseconds.



17-Byte Character Date and Time Value Structure

This table shows the structure used for the input and output variables when the format is *YYMD, *MDYY, *DMYY, and *LONGJUL and the precision indicator specifies milliseconds.



19-Byte Character Date and Time Value Structure

This table shows the structure used for the input and output variables when the format is *JOB, *SYSVAL, *YMD, *MDY, *DMY, and *JUL and the precision indicator specifies microseconds.



20-Byte Character Date and Time Value Structure

This table shows the structure used for the input and output variables when the format is *YYMD, *MDYY, *DMYY, and *LONGJUL and the precision indicator specifies microseconds..



DOSGetDateTime Value Structure

This table shows the structure used for the output variable.



Time Zone Information Value Structure

This table shows the structure used for the time zone information output parameter. If *UTC is specified for the output time zone, or if the input and output time zone parameter values are the same and the input variable contains a date that is outside the supported date range (from August 25, 1928, 00:00:00.000000 to May 09, 2071, 00:00:00.000000), then all binary fields will be set to 0 and all character fields will be set to blanks.



Field Descriptions

Bytes available. The number of bytes of data available to be returned. All available data is returned if enough space is provided.

Bytes returned. The number of bytes of data returned.

Current abbreviated name. The abbreviated, or short, name for the time zone. This field will contain either the Standard Time or Daylight Saving Time abbreviated name depending on whether or not Daylight Saving Time is in effect. If the time zone description uses a message to specify the current abbreviated name and the message cannot be retrieved, this field returns *N. This can occur when the caller of the API is not authorized to the message file or its library, the message file cannot be found or the message does not exist in the message file.

Current Daylight Saving Time indicator. Indicates whether or not the output date and time (output variable converted based on the output time zone) is observing Daylight Saving Time or not. Valid values that are returned are:

Current full name. The full, or long, name for the time zone. This field will contain either the Standard Time or Daylight Saving Time full name depending on whether or not Daylight Saving Time is in effect. If the time zone description uses a message to specify the current full name and the message cannot be retrieved, this field returns *N. This can occur when the caller of the API is not authorized to the message file or its library, the message file cannot be found or the message does not exist in the message file.

Current message identifier. The identifier of the message that contains the current full and abbreviated names. This field will be *NONE if a message was not specified when the time zone description was created.

Current offset. The time difference, in minutes, between the output time zone and Coordinated Universal Time (UTC). This value has been adjusted for Daylight Saving Time, if necessary.

Message file library. The name of the library that contains the message file. The field will contain all blanks if the current message identifier is *NONE.

Message file name. The name of the file that contains the current message. The field will contain *NONE if the current message identifier is *NONE.

Reserved. An unused field.

Time zone description name. The name of the time zone description that is associated with the output time zone. If *SYS or *JOB was specified for the output time zone and a time zone has not been set for the Time zone (QTIMZON) system value, this field returns *N.

Year offset. The number of years that the current year in the calendar system used with this time zone differs from the current Gregorian year. The range is -140 to 140.


Usage Notes

When converting an input date from a 2-digit year format to a *DTS time-stamp format without time zone conversion, the supported date range is from August 23, 1928, 12:03:06.314752 (.315 for milliseconds) to May 10, 2071, 11:56:53.685240 (.685 for milliseconds). Converting an input date that is outside this range will result in an output date within this range.

When converting an input date from a 4-digit year format to a *DTS time-stamp format without time zone conversion, the supported date range is from August 24, 1928, 00:00:00.000000 to May 09, 2071, 23:59:59.999999 (.999 for milliseconds). Converting an input date that is outside this range will result in error message CPF1060.

When converting an input date from a 4-digit year format to a 2-digit year format without time zone conversion, the supported date range is from January 1, 1900, 00:00:00.000000 to December 31, 2899, 23:59:59.999999 (.999 for milliseconds). Converting an input date that is outside this range will result in error message CPF1060.

When converting an input date from a 4-digit year format to a 4-digit year format without time zone conversion, the supported date range is from January 1, 0001, 00:00:00.000000 to December 31, 9999, 23:59:59.999999 (.999 for milliseconds). Converting an input date that is outside this range will result in error message CPF1060.

When converting an input date from 2-digit year format to a 2-digit year format without time zone conversion, the supported date range is from January 1, 1900, 00:00:00.000000 to December 31, 2899, 23:59:59.999999 (.999 for milliseconds). The century digit of the input variable is copied into the output variable without validation.

When converting an input date from 2-digit year format to a 4-digit year format without time zone conversion, the supported date range is from January 1, 1900, 00:00:00.000000 to December 31, 2899, 23:59:59.999999 (.999 for milliseconds).

When converting an input date from a *DTS time-stamp format to an output date of any format without time zone conversion, the supported date range is from August 23, 1928, 12:03:06.314752 (.315 for milliseconds) to May 10, 2071, 11:56:53.685240 (.685 for milliseconds).

When converting an input date of any format to an output date of any format that involves time zone conversion as well, the supported date range is from August 25, 1928, 00:00:00.000000 to May 08, 2071, 23:59:59.999999 (.999 for milliseconds). Converting an input date that is outside this range will result in error message CPF1060.

When moving from Standard Time (ST) to Daylight Saving Time (DST) there is a window of time (1 hour) that does not occur. Any time zone conversion where the input variable date and time value is within this window will result in error message CPF1060.

When moving from Daylight Saving Time (DST) to Standard Time there is a window of time (1 hour) that repeats. For example, if DST ends on a given day at 02:00AM, then the segment of time from 01:00:00.000000 to 01:59:59.999999 on that day repeats. The first segment of repeated time is the DST segment. The second segment of repeated time is the Standard Time segment. It is possible using time zone conversion to have the output variable date and time value end up in either segment. If you are retrieving time zone information, the current Daylight Saving Time indicator will be set accordingly. By default, for any time zone conversion the input variable that is within this window of time that repeats is considered part of the DST segment. However, you can use the optional Input time indicator parameter to cause the input variable to be considered within the Standard Time segment. You can copy the resultant current DST indicator into the Input time indicator parameter when converting back and forth between time zones. For example, when converting a date and time value from *UTC to time zone A, the resultant time is 01:15:00 AM and the current DST indicator returned is 0, which means the resultant time is Standard Time. In order to obtain the original *UTC value when converting back to *UTC from time zone A, the current DST indicator value should be copied to the Input time indicator parameter. This will cause the date and time value to be treated as Standard Time rather than as the default, Daylight Saving Time.

You can convert any input format except *CURRENT to the same output format without receiving an error (time zone conversion is not specified, or if specified, the input and output time zone parameter values must be the same and the time zone information length must be 0 as well). For these cases, the input variable is copied into the output variable without validation.

When converting one character date format (that is, anything other than *CURRENT, the current machine-clock time, *DTS, the system time-stamp, or any specified time zone conversion) to another character date format, the date information is validated and converted. However, the time portion of the input variable is copied into the output variable without validation.

When requesting time zone conversion with different input and output time zone values, or when requesting time zone information, the time portion is validated and converted as well as the date portion.

When converting a character date and time value to *DTS and back to character format using microseconds precision, there is a rounding error of minus 1 to minus 7 microseconds. If you specify a precision of microseconds, it is recommended that you use a microsecond value that is evenly divisible by 8.

The system has the ability to manage a year offset that specifies the number of years that the current year in the calendar system used with this time zone differs from the current Gregorian year. When the input time format is *CURRENT, the date returned will be in the non-Gregorian year which takes the year offset into account. When specifying an input time zone value that is not *UTC and an output time zone value of *UTC, the year offset is removed along with the time zone offset. The converted output will be in the UTC time zone (based on the Greenwich meridian) and will be in the Gregorian year. To get a result that includes the year offset, specify an output time zone that defines Greenwich Mean Time such as the IBM-supplied Q0000GMT and that also contains the desired year offset. The converted output will be in the GMT time zone (same as UTC time zone) and will also be in the non-Gregorian year.


Error Messages



API introduced: V2R1

[ Back to top | Date and Time APIs | Miscellaneous APIs | APIs by category ]