We can use SQLite’s DATE()
function to return the first Monday of each month for a given year, based on the date we provide.
But it’s not limited to Monday. We can also get the first Tuesday, Wednesday, Thursday, Friday, etc of each month.
Example
We can alternatively use code like the following to return the first Monday of each month throughout the year:
SELECT
DATE('2025-10-20', 'start of year', 'weekday 1') AS "Jan",
DATE('2025-10-20', 'start of year', '+1 month', 'weekday 1') AS "Feb",
DATE('2025-10-20', 'start of year', '+2 months', 'weekday 1') AS "Mar",
DATE('2025-10-20', 'start of year', '+3 months', 'weekday 1') AS "Apr",
DATE('2025-10-20', 'start of year', '+4 months', 'weekday 1') AS "May",
DATE('2025-10-20', 'start of year', '+5 months', 'weekday 1') AS "Jun",
DATE('2025-10-20', 'start of year', '+6 months', 'weekday 1') AS "Jul",
DATE('2025-10-20', 'start of year', '+7 months', 'weekday 1') AS "Aug",
DATE('2025-10-20', 'start of year', '+8 months', 'weekday 1') AS "Sep",
DATE('2025-10-20', 'start of year', '+9 months', 'weekday 1') AS "Oct",
DATE('2025-10-20', 'start of year', '+10 months', 'weekday 1') AS "Nov",
DATE('2025-10-20', 'start of year', '+11 months', 'weekday 1') AS "Dec";
Result:
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 2025-01-06 2025-02-03 2025-03-03 2025-04-07 2025-05-05 2025-06-02 2025-07-07 2025-08-04 2025-09-01 2025-10-06 2025-11-03 2025-12-01
Here, we call the DATE()
function twelve times. We use the same date each time, and most of the arguments are the same. The only thing that changes is how much we add to the start of the year.
We use start of year
to return the date back to the first day of the year. We then use additional modifiers to modify that date accordingly.
When we don’t add any months to the date, we return the first Monday of January. Adding +1 month
returns the first Monday of February, and so on.
The weekday 1
modifier moves the date forward to the next Monday. Sunday is 0, Monday is 1, Tuesday is 2, and so on, so if we wanted Tuesday for example, we’d use weekday 2
instead.
Using the Current Date
The following example uses the current date:
SELECT
DATE('now') AS "Now",
DATE('now', 'start of year', 'weekday 1') AS "Jan",
DATE('now', 'start of year', '+1 month', 'weekday 1') AS "Feb",
DATE('now', 'start of year', '+2 months', 'weekday 1') AS "Mar",
DATE('now', 'start of year', '+3 months', 'weekday 1') AS "Apr",
DATE('now', 'start of year', '+4 months', 'weekday 1') AS "May",
DATE('now', 'start of year', '+5 months', 'weekday 1') AS "Jun",
DATE('now', 'start of year', '+6 months', 'weekday 1') AS "Jul",
DATE('now', 'start of year', '+7 months', 'weekday 1') AS "Aug",
DATE('now', 'start of year', '+8 months', 'weekday 1') AS "Sep",
DATE('now', 'start of year', '+9 months', 'weekday 1') AS "Oct",
DATE('now', 'start of year', '+10 months', 'weekday 1') AS "Nov",
DATE('now', 'start of year', '+11 months', 'weekday 1') AS "Dec";
Result:
Now Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 2022-03-10 2022-01-03 2022-02-07 2022-03-07 2022-04-04 2022-05-02 2022-06-06 2022-07-04 2022-08-01 2022-09-05 2022-10-03 2022-11-07 2022-12-05