Created
March 4, 2019 23:53
-
-
Save bas080/4fcc0dc9d732223d1a35157f5b78c641 to your computer and use it in GitHub Desktop.
Weeks since epoch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Depending on what you sonsider the start of the week, you can either subtract 3 or 2 days. The week in which the epoch occured is the 0 week. | |
select CEIL(EXTRACT(DAYS FROM (('1970-01-04'::timestamp - '1970-01-01') - (INTERVAL '3 days'))) / 7); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment