LAST_DAY (Lakehouse v1)
Returns the last day of the specified interval (week, month, quarter, or year) based on the provided date or timestamp.
Analyze Syntax
Section titled “Analyze Syntax”func.last_day(<date_expression>, <interval>)Analyze Examples
Section titled “Analyze Examples”func.last_day(func.to_date('2024-11-13'), 'month')┌──────────────────────────────────────────────────────┐│ func.last_day(func.to_date('2024-11-13'), 'month') │├──────────────────────────────────────────────────────┤│ 2024-11-30 │└──────────────────────────────────────────────────────┘SQL Syntax
Section titled “SQL Syntax”LAST_DAY(<date_expression>, <interval>)| Parameter | Description |
|---|---|
<date_expression> | A DATE or TIMESTAMP value to calculate the last day of the specified interval. |
<interval> | The interval type for which to find the last day. Accepted values are week, month, quarter, and year. |
Return Type
Section titled “Return Type”Date.
SQL Examples
Section titled “SQL Examples”Let’s say you want to determine the billing date, which is always the last day of the month, based on an arbitrary date of a transaction (e.g., 2024-11-13):
SELECT LAST_DAY(to_date('2024-11-13'), month) AS billing_date;
┌──────────────┐│ billing_date │├──────────────┤│ 2024-11-30 │└──────────────┘