FORMAT_TIMESTAMP()
function returns a given timestamp value in a specified format. Its syntax is illustrated below:
FORMAT_TIMESTAMP()
functionFORMAT_TIMESTAMP()
function to convert a given timestamp into a timestamp format as specified in the function arguments.
YYYY
is the four-digit year 2022MM
is the month: 05DD
is the day: 30HH
is the hour: 5MI
is the minute: 30SS
is the second: 04FORMAT_TIMESTAMP()
function using multiple spacesFORMAT_TIMESTAMP()
when given multiple spaces in the input string, omits the spaces and only returns the correct timestamp value. Let’s see how it works using the following example:
FORMAT_TIMESTAMP()
function if the input value of the year is less than 4 digitsFORMAT_TIMESTAMP()
will adjust the year to the nearest year value if the input argument has less than the required number of digits i.e., less than 4. To see how it works, look at the example below:
09
has been changed to the nearest four-digit year i.e., 2009
. Similarly, 70
will become 1970
, and 10
will become 2010,
etc.