2014-05-05 23:13:06 +08:00
|
|
|
-- Convert string to date
|
|
|
|
--
|
2015-03-04 00:09:57 +08:00
|
|
|
DROP FUNCTION IF EXISTS CDB_StringToDate(character varying);
|
2014-05-05 23:13:06 +08:00
|
|
|
CREATE OR REPLACE FUNCTION CDB_StringToDate(input character varying)
|
2015-03-03 17:49:33 +08:00
|
|
|
RETURNS TIMESTAMP AS $$
|
|
|
|
DECLARE output TIMESTAMP;
|
2014-05-05 23:13:06 +08:00
|
|
|
BEGIN
|
|
|
|
BEGIN
|
|
|
|
output := input::date;
|
|
|
|
EXCEPTION WHEN OTHERS THEN
|
|
|
|
BEGIN
|
|
|
|
SELECT to_timestamp(input::integer) INTO output;
|
|
|
|
EXCEPTION WHEN OTHERS THEN
|
|
|
|
RETURN NULL;
|
|
|
|
END;
|
|
|
|
END;
|
|
|
|
RETURN output;
|
|
|
|
END;
|
|
|
|
$$
|
2017-10-24 20:16:56 +08:00
|
|
|
LANGUAGE 'plpgsql' IMMUTABLE STRICT PARALLEL UNSAFE;
|