SQLite’s DATE()
function provides us with the ability to return the date of the first instance of a given day of a given month. Therefore, we can use it to return the first Monday of a given month. We can also use it to return the first Tuesday, Wednesday, Thursday, Friday, etc.
We can use DATETIME()
if we want a datetime value to be returned.
Example
SELECT DATE('2025-10-20', 'start of month', 'weekday 1');
Result:
2025-10-06
In this case, the first Monday of the given month occurs on 2025-10-06.
The start of month
and weekday 1
modifiers modify the date given at the first argument. Sunday is 0, Monday is 1, Tuesday is 2, and so on. Therefore, we use a value of weekday 1
to select Monday.
First Monday of the Current Month
This example walks through the process using the current date:
SELECT
DATE('now') AS "Now",
DATE('now', 'start of month') AS "Start of Month",
DATE('now', 'start of month', 'weekday 1') AS "First Monday";
Result:
Now Start of Month First Monday ---------- -------------- ------------ 2022-03-09 2022-03-01 2022-03-07
This example shows us the date at each stage of its modification. We use now
to return the current date, then start of month
to move it back to the start of the month, then weekday 1
to move the date forward to the first Monday.
The DATETIME()
Function
We can also use the DATETIME()
function to do the same thing. The difference is that it includes the time portion:
SELECT DATETIME('2025-10-20', 'start of month', 'weekday 1');
Result:
2025-10-06 00:00:00