Overloads CDB_DateToNumber() and adds test
This commit is contained in:
parent
e4ce12d1a3
commit
186ed34ee5
@ -1,5 +1,21 @@
|
||||
-- Convert timestamp to double precision
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION CDB_DateToNumber(input timestamp)
|
||||
RETURNS double precision AS $$
|
||||
DECLARE output double precision;
|
||||
BEGIN
|
||||
BEGIN
|
||||
SELECT extract (EPOCH FROM input) INTO output;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
RETURN NULL;
|
||||
END;
|
||||
RETURN output;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' STABLE STRICT;
|
||||
|
||||
-- Convert timestamp with time zone to double precision
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION CDB_DateToNumber(input timestamp with time zone)
|
||||
RETURNS double precision AS $$
|
||||
DECLARE output double precision;
|
||||
|
2
test/CDB_DateToNumberTest.sql
Normal file
2
test/CDB_DateToNumberTest.sql
Normal file
@ -0,0 +1,2 @@
|
||||
SELECT * FROM CDB_DateToNumber('1999-01-08 00:00:00+00'::timestamp);
|
||||
SELECT * FROM CDB_DateToNumber('1999-01-08 00:00:00+00'::timestamp with time zone);
|
2
test/CDB_DateToNumberTest_expect
Normal file
2
test/CDB_DateToNumberTest_expect
Normal file
@ -0,0 +1,2 @@
|
||||
915753600
|
||||
915753600
|
Loading…
Reference in New Issue
Block a user