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:

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

Want to build AI systems that actually work?

Download my expert-crafted GenAI Transformation Guide for Data Teams and discover how to properly measure AI performance, set up guardrails, and continuously improve your AI solutions like the pros.

Want to build AI systems that actually work?

Download my expert-crafted GenAI Transformation Guide for Data Teams and discover how to properly measure AI performance, set up guardrails, and continuously improve your AI solutions like the pros.

Older post

How to make an unconditional join in Redshift

LEFT OUTER JOIN ON 1=1 in Redshift

Newer post

How to purge a Kafka topic

How to remove all messages from a Kafka topic

Are you looking for an experienced AI consultant? Do you need assistance with your RAG or Agentic Workflow?
Book a Quick Consultation, send me a message on LinkedIn. Book a Quick Consultation or send me a message on LinkedIn

>