SQLite Forum

Week numbers in queries
Login
Hi.

Take a look at this:
`
 8:20:46.21>sqlite3
SQLite version 3.30.1 2019-10-10 20:19:45
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> SELECT strftime('%W','2019-01-01');
00
sqlite>  SELECT strftime('%W','2019-01-02');
00
sqlite>  SELECT strftime('%W','2019-01-03');
00
sqlite>  SELECT strftime('%W','2019-01-04');
00
sqlite>  SELECT strftime('%W','2019-01-05');
00
sqlite>  SELECT strftime('%W','2019-01-06');
00
sqlite>  SELECT strftime('%W','2019-01-07');
01
sqlite>  SELECT strftime('%W','2020-01-01');
00
sqlite>  SELECT strftime('%W','2020-01-02');
00
sqlite>  SELECT strftime('%W','2020-01-03');
00
sqlite>  SELECT strftime('%W','2020-01-04');
00
sqlite>  SELECT strftime('%W','2020-01-05');
00
sqlite>  SELECT strftime('%W','2020-01-06');
01
sqlite>  SELECT strftime('%W','2020-01-06');
`

It may be that what you think week 17 is , may not be calculated as week 17. It depends a lot on how you want to define a 'week' and what you are
going to use it for. I had this problem once, and some of the folks here kindly guided me correctly.  Play around with the dates, and you'll see some holes.  I hope this helps.

josé