$Sir DateCnv: Difference between revisions
m (add link) |
m (remove category) |
||
Line 62: | Line 62: | ||
and see <var>[[Sir_Date_Err]]</var>. </p> | and see <var>[[Sir_Date_Err]]</var>. </p> | ||
[[Category:Sir2000 User Language Tools $functions]] | [[Category:Sir2000 User Language Tools $functions]] |
Revision as of 23:57, 24 September 2015
Convert datetime to different format
Note: This $function require the Sir2000 User Language Tools product.
The $Sir_DateCnv function expects a datetime format string for the input string, a datetime format for the output string, and a datetime value to be converted. It also accepts an optional CENTSPAN value and an optional error control string.
$Sir_DateCnv returns the input datetime converted to the output format.
Syntax
%odat = $Sir_DateCnv(infmt, outfmt, dat, [span], [errctl])
Where:
%odat | Set to the value of dat, converted from the format in infmt to the format in outfmt, unless an error is detected. |
---|---|
infmt | Datetime format string for dat. Refer to Datetime string formats for an explanation of valid datetime formats and valid dates. Strict matching is used for infmt. |
outfmt | Datetime format string for function output (%odat). |
dat | Input datetime string. |
span | Optional CENTSPAN value, default is -50. Refer to Using CENTSPAN. |
errctl | Optional error control string, refer to Datetime error handling. |
Example
The following fragment prints the string 19970101
:
Print $sir_datecnv('YYMMDD', 'YYYYMMDD', '970101', 1950)
Error conditions
$Sir_DateCnv returns a string composed of all asterisks (*), whose length is the shorter of the length of the output date format string or 32, in the following error cases:
- infmt or outfmt is not a valid datetime format string.
- dat does not match infmt.
- dat is outside of range permitted for infmt or that permitted for outfmt.
- span is invalid.
For more information about error handling, see the APPDATE command, and see Sir_Date_Err.