number_to_date
Use the number_to_date function to convert a numerical date value into the ISO 8601 YYYYMMDD format based on a custom template.
number_to_date ( date; template )
This function returns a value of type NUMBER.
The function has two parameters:
- date, type NUMBER. The date to be converted. Fractions are ignored.
- template, type TEXT. A template describing how to interpret date.
template is a mask describing how the digits in date must be interpreted. It must contain the following three components in the correct order:
- DD for the day part
- MM for the month part
- YY, YYY, or YYYY for the year part
- YY represents a year in the 2000s (2000-2099).
- YYY represents a year in the 1900s (1900-1999) for values between 0 and 99, or a year in the 2000s (2000-2099) for values between 100 and 199.
- YYYY represents the year without further interpretation.
date is considered to be left-padded with 0's if the template requires more digits than the value of date provides. If a component is omitted from the template, the corresponding part in the result is set to 0. The result of the number_to_date function for invalid templates is undefined.
Examples
number_to_date (20150203; "YYYYDDMM") results in 20150302
number_to_date (150302; "YYMMDD") results in 20150302
number_to_date (150302; "YYYMMDD") results in 19150302
number_to_date (201503; "YYYYMM") results in 20150300
number_to_date (2015; "DDMMYYYY") results in 20150000