This function returns the truncated date to the unit defined by the format. This will aim to return the first day of the specified month on the first day of the specified year.
Supported formats: MONTH/MON/MM, YEAR/YYYY/YYY.
Syntax: TRUNC(string date, string format)
Examples:
SELECT TRUNC(‘2020-04-26 13:04:05.000’, “MM”);
This returns 2020-04-01
You can use “MM” or “MONTH” or “MON”
SELECT TRUNC(‘2020-04-26 13:04:05.000’, “YY”);
This returns 2020-01-01
You can use “YY” or “YEAR” or “YYYY”
Hope you find this article helpful.
Please click on the follow button to receive updates on latest posts.
4 comments