Copy cartodb lib/sql scripts from CDB_CartodbfyTable branch
This commit is contained in:
19
scripts-available/CDB_StringToDate.sql
Normal file
19
scripts-available/CDB_StringToDate.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Convert string to date
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION CDB_StringToDate(input character varying)
|
||||
RETURNS date AS $$
|
||||
DECLARE output DATE DEFAULT NULL;
|
||||
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;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' STABLE STRICT;
|
||||
Reference in New Issue
Block a user