We can use SQLite’s DATE()
function to return the date of the first instance of a given day of a given year. Therefore, we can use it to return the first Monday of a given year. 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 year', 'weekday 1');
Result:
2025-01-06
In this case, the first Monday of the given year occurs on 2025-01-06.
The start of year
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 Year
Here’s an example that walks through the process using the current date:
SELECT
DATE('now') AS "Now",
DATE('now', 'start of year') AS "Start of Year",
DATE('now', 'start of year', 'weekday 1') AS "First Monday";
Result:
Now Start of Year First Monday ---------- ------------- ------------ 2022-03-09 2022-01-01 2022-01-03
This example shows us the date at each stage of its modification. We use now
to return the current date, then start of year
to move it back to the start of the year, 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 year', 'weekday 1');
Result:
2025-01-06 00:00:00