Get the last day of the month in Redshift

This article is a part of my "100 data engineering tutorials in 100 days" challenge. (86/100)

Redshift gives us an easy way to get the date of the last day of a month. We no longer need to do date based calculations or tricks with date parsing. All we need is the last_day function.

The last_day function requires one parameter: a date or a timestamp. As the return value we will get the last day of the same month as the one given in the parameter. For example, if I pass 2020-12-18 to the function, I will get 2020-12-31:

1
select last_day(to_date('2020-12-18','YYYY-MM-DD'))

Subscribe to the newsletter and join the free email course.


Remember to share on social media!
If you like this text, please share it on Facebook/Twitter/LinkedIn/Reddit or other social media.

If you want to contact me, send me a message on LinkedIn or Twitter.

Would you like to have a call and talk? Please schedule a meeting using this link.


Bartosz Mikulski
Bartosz Mikulski * data/machine learning engineer * conference speaker * co-founder of Software Craft Poznan & Poznan Scala User Group

Subscribe to the newsletter and get access to my free email course on building trustworthy data pipelines.

Do you want to work with me at riskmethods?

REMOTE position (available in Poland or Germany)