Created
July 9, 2020 13:20
-
-
Save romuald/291dadf2840bad3bbee44688d9e8bfaf to your computer and use it in GitHub Desktop.
Converts a UUID1 variable to a timestamp
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
SET @uuid='31ae75f0-cbe0-11e8-a147-bc5ff4690f6a'; | |
SELECT | |
IF(SUBSTRING(@uuid, 15, 1) = '1', | |
'1582-10-15' + INTERVAL ( | |
CONV(CONCAT(SUBSTRING(@uuid, 16, 3), SUBSTRING(@uuid, 10, 4), SUBSTRING(@uuid, 1, 8)), | |
16, 10) | |
/ 10000000) SECOND, | |
NULL) AS uuid_as_timestamp; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment