2014-05-05 23:13:06 +08:00
|
|
|
-- Convert string to date
|
|
|
|
--
|
2019-05-31 21:29:28 +08:00
|
|
|
DROP FUNCTION IF EXISTS @extschema@.CDB_StringToDate(character varying);
|
|
|
|
CREATE OR REPLACE FUNCTION @extschema@.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;
|