Last active
January 11, 2019 08:14
-
-
Save jordan-thoms/d14cd1a2efeb2b5fab01174d9de2bea9 to your computer and use it in GitHub Desktop.
Postgres Function to convert timestamp to excel formatted date
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
CREATE OR REPLACE FUNCTION excel_time(in timestamp, out double precision) | |
AS $$ | |
SELECT (EXTRACT(epoch FROM $1)/86400) + 25569 | |
$$ | |
LANGUAGE SQL IMMUTABLE PARALLEL SAFE; | |
CREATE OR REPLACE FUNCTION excel_time(in timestamptz, out double precision) | |
AS $$ | |
SELECT (EXTRACT(epoch FROM $1)/86400) + 25569 | |
$$ | |
LANGUAGE SQL IMMUTABLE PARALLEL SAFE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment