Skip to main content
Version: 24.3.x

Categories: Date/Time

LAST_DAY

Returns the last day of the month for the specified date or timestamp.

Syntax

LAST_DAY(date_timestamp_expression string) → date

  • date_timestamp_expression: A DATE or TIMESTAMP expression.

Examples

LAST_DAY example
SELECT LAST_DAY('2009-01-12 12:58:59')
-- 2009-01-31
LAST_DAY example
SELECT pickup_datetime, LAST_DAY(pickup_datetime) AS "last_day" 
FROM Samples."samples.dremio.com"."NYC-taxi-trips"
LIMIT 3
-- pickup_datetime, last_day
-- 2013-05-27 19:15:00.000, 2013-05-31
-- 2013-05-31 16:40:00.000, 2013-05-31
-- 2013-05-27 19:03:00.000, 2013-05-31

Usage Notes

The return value is always a date regardless of whether date_timestamp_expression is a date or a timestamp.