On 2-5-2019 22:17, Jose Isaias Cabrera wrote:
I found this very interesting,

15:52:46.71>sqlite3
SQLite version 3.28.0 2019-04-16 19:49:53
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

I expected 2019-01-01 to be part of week 1, since it was Tuesday.  So, back to 
the drawing board. ;-)  Thanks.

It's more complex than that

sqlite> select strftime('%W','2018-12-29');
52
sqlite> select strftime('%W','2018-12-30');
52
sqlite> select strftime('%W','2018-12-31');
53
sqlite> select strftime('%W','2019-01-01');
00
sqlite>


As others have noted, it's a question of definition, and which definition do you follow?

- Does a week start on Sunday, or on Monday?
- Is week #1 the week in which the month starts, the first complete week within the month, or the first week with at least 4 days?

Even EXCEL (Microsoft) has problems with this, that's why they implemented server WEEKNUM functions

=WEEKNUM(<date>;2) for the 31th december returns 53 (the second parameter is used to specify when a week starts)

=ISO.WEEKNUM(<date>) for the same date returns 1


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to