pears.NetStringToTimestamp
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
CREATE FUNCTION "pears"."NetStringToTimestamp"( IN "sDateTime" CHAR(25) ) RETURNS TIMESTAMP BEGIN SET "sDateTime" = "trim"("sDateTime"); -- remove trailing and leading white space IF "sDateTime" REGEXP '^\\d{4}\\-\\d{2}\\-\\d{2}(T|\\040)\\d{2}:\\d{2}($|Z$|\\+00:00$|:\\d{2}($|Z$|\\+00:00$))' THEN -- check to make sure it is formatted correctly SET "sDateTime" = "REPLACE"("sDateTime",'T',' '); SET "sDateTime" = "REPLACE"("sDateTime",'Z',''); SET "sDateTime" = "REPLACE"("sDateTime",'+00:00',''); RETURN CONVERT(TIMESTAMP,"sDateTime",120) ELSE RETURN NULL END IF END /* DOC 2018-08-03 ET create function which to change ISO string to timestamp. ISO string may include or not include seconds. */