Skip to content

Instantly share code, notes, and snippets.

@jordan-thoms
Last active January 11, 2019 08:14
Show Gist options
  • Save jordan-thoms/d14cd1a2efeb2b5fab01174d9de2bea9 to your computer and use it in GitHub Desktop.
Save jordan-thoms/d14cd1a2efeb2b5fab01174d9de2bea9 to your computer and use it in GitHub Desktop.
Postgres Function to convert timestamp to excel formatted date
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