All Downloads are FREE. Search and download functionalities are using the official Maven repository.

db.migration.V65__fix_dv_date_time_function.sql Maven / Gradle / Ivy

There is a newer version: 0.32.0
Show newest version
-- Removes 'Z' when timezone is NULL

CREATE OR REPLACE FUNCTION ehr.js_dv_date_time(TIMESTAMP, TEXT)
    RETURNS JSON AS
$$
DECLARE
date_time ALIAS FOR $1;
    time_zone ALIAS FOR $2;
BEGIN

    IF (date_time IS NULL)
    THEN
        RETURN NULL;
END IF;

    IF (time_zone IS NULL)
    THEN
        time_zone := '';
END IF;

RETURN
    json_build_object(
            '_type', 'DV_DATE_TIME',
            'value',to_char(date_time, 'YYYY-MM-DD"T"HH24:MI:SS.MS"'||time_zone||'"')
        );
END
$$
LANGUAGE plpgsql;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy