Last active
August 8, 2019 09:57
-
-
Save wbrframe/092c9de78b8f9c68825b7d018e90fd92 to your computer and use it in GitHub Desktop.
Generate microseconds for exists dates that without microseconds
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
# For example, you store dates in the type `timestamp with timezone`: | |
2019-08-04 11:13:17+00 | |
# This query generates randomly microseconds for a date: | |
UPDATE <table> SET <field> = TO_TIMESTAMP(replace(to_char(<field>, 'YYYY-MM-DD HH24:MI:SS.SS%m%OF'), '%m%', (floor(random()*(10000-1+1))+1)::text), 'YYYY-MM-DD HH24:MI:SS.US') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment