end_of_month

datetime

Returns the last day of the month for a given date

Syntax

end_of_month(date)

Parameters

date (date|timestamp)

The date to find the end of month for

Returns

date

The last day of the month

Examples

Get last day of January 2024
Input:
end_of_month("2024-01-15")
Output:
"2024-01-31"
Handles leap years correctly
Input:
end_of_month("2024-02-15")
Output:
"2024-02-29"
Get month end from field
Input:
.date | end_of_month
Output:
"2024-01-31"
Get month-to-date and future
Input:
map(select(.date <= end_of_month(today())))
Output:
Filter through end of current month

The end_of_month() function returns the last day of the month for a given date, correctly handling months with different numbers of days and leap years.

Usage

Use end_of_month() to find month boundaries, calculate month-based date ranges, validate dates within a month, or filter data through the end of a month.