---
title: "Get the last day of the month in Redshift"
description: "How to use the last_day function in Redshift"
author: "Bartosz Mikulski"
author_bio: "Principal AI Engineer & MLOps Architect. I bridge the gap between \"it works in a notebook\" and \"it works for 200 million users.\""
author_url: https://mikulskibartosz.name
author_linkedin: https://www.linkedin.com/in/mikulskibartosz/
author_github: https://github.com/mikulskibartosz
canonical_url: https://mikulskibartosz.name/last-day-of-month-in-redshift
---

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`:

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

