start_of_month
datetimeReturns the first day of the month for a given date
Syntax
start_of_month(date) Parameters
date (date|timestamp) The date to find the start of month for
Returns
date The first day of the month
Examples
Get first day of January 2024
Input:
start_of_month("2024-01-15") Output:
"2024-01-01" Get month start from field
Input:
.date | start_of_month Output:
"2024-01-01" Get current month data
Input:
map(select(.date >= start_of_month(today()))) Output:
Filter month-to-date records The start_of_month() function returns the first day of the month for a given date, useful for calculating month boundaries and filtering month-to-date data.
Usage
Use start_of_month() to find month boundaries, filter data for the current month, group by month periods, or calculate month-based date ranges.