Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

LAST_DAY function

Focus mode
LAST_DAY function - Amazon Redshift

LAST_DAY returns the date of the last day of the month that contains date. The return type is always DATE, regardless of the data type of the date argument.

For more information about retrieving specific date parts, see DATE_TRUNC function.

Syntax

LAST_DAY( { date | timestamp } )

Arguments

date | timestamp

A column of data type DATE or TIMESTAMP or an expression that implicitly evaluates to a DATE or TIMESTAMP type.

Return type

DATE

Examples

The following example returns the date of the last day in the current month.

select last_day(sysdate); last_day ------------ 2014-01-31

The following example returns the number of tickets sold for each of the last 7 days of the month. The values in the SALETIME column are timestamps.

select datediff(day, saletime, last_day(saletime)) as "Days Remaining", sum(qtysold) from sales where datediff(day, saletime, last_day(saletime)) < 7 group by 1 order by 1; days remaining | sum ---------------+------- 0 | 10140 1 | 11187 2 | 11515 3 | 11217 4 | 11446 5 | 11708 6 | 10988 (7 rows)

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.