Created
February 19, 2021 14:47
-
-
Save rodo/181a70a732afc0a60046ff92fea67982 to your computer and use it in GitHub Desktop.
get_random_date for PostgreSQL
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
| [local]:5412 rodo@rodo=# SELECT get_random_date(), | |
| get_random_date('3 week') as rand, | |
| get_random_date('3 week', 'past') as past, | |
| get_random_date('3 week', 'future') as future, | |
| generate_series(1,7); | |
| get_random_date | rand | past | future | generate_series | |
| -----------------+------------+------------+------------+----------------- | |
| 2017-03-01 | 2021-02-27 | 2021-02-19 | 2021-03-04 | 1 | |
| 2007-03-25 | 2021-03-06 | 2021-02-15 | 2021-02-25 | 2 | |
| 2019-09-01 | 2021-02-21 | 2021-02-14 | 2021-03-02 | 3 | |
| 2013-06-23 | 2021-02-06 | 2021-02-09 | 2021-02-22 | 4 | |
| 2037-04-17 | 2021-02-12 | 2021-02-16 | 2021-02-27 | 5 | |
| 2009-11-07 | 2021-03-12 | 2021-02-09 | 2021-02-26 | 6 | |
| 2028-06-28 | 2021-02-17 | 2021-01-30 | 2021-03-01 | 7 | |
| (7 rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment