Last active
September 12, 2018 00:35
-
-
Save joebartels/aaf35fd182a454610c589b3d996051c7 to your computer and use it in GitHub Desktop.
using generate_series to create bunch of random dates throughout "a year"
This file contains hidden or 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
with days as ( | |
select * | |
from generate_series( | |
'1988-01-01T00:00:00'::timestamptz, | |
'2019-01-01T00:00:00'::timestamptz - '1 day'::interval, | |
'1 day'::interval | |
) as date | |
) | |
-- uncomment to insert into the table | |
-- insert into cycling_entry (date, km_cycled) | |
select date + ('1 day'::interval * int_between(-7, 7)) | |
+ ('1 hour'::interval * int_between(0, 24)) | |
+ ('1 minute'::interval * int_between(0, 60)) as date, | |
int_between(0, 100) as km_cycled | |
from days; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment