IDEMPIERE-5481 PostgreSQL: trunc(timestamp,format) missing version for TIMESTAMP WITHOUT TIME ZONE (#1569)
This commit is contained in:
parent
2ff6378720
commit
222c201d78
|
@ -33,7 +33,7 @@ BEGIN
|
|||
END;
|
||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
||||
|
||||
CREATE OR REPLACE FUNCTION trunc(datetime TIMESTAMP WITH TIME ZONE, format varchar)
|
||||
CREATE OR REPLACE FUNCTION trunc(datetime TIMESTAMP WITHOUT TIME ZONE, format varchar)
|
||||
RETURNS DATE AS $$
|
||||
BEGIN
|
||||
IF format = 'Q' THEN
|
||||
|
@ -52,6 +52,13 @@ BEGIN
|
|||
END;
|
||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
||||
|
||||
CREATE OR REPLACE FUNCTION trunc(datetime TIMESTAMP WITH TIME ZONE, format varchar)
|
||||
RETURNS DATE AS $$
|
||||
BEGIN
|
||||
RETURN trunc(cast(datetime as timestamp without time zone), format);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
||||
|
||||
CREATE OR REPLACE FUNCTION trunc(i INTERVAL)
|
||||
RETURNS INTEGER AS $$
|
||||
BEGIN
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
SELECT register_migration_script('202211180700_IDEMPIERE-5481.sql') FROM dual;
|
||||
|
||||
-- PostgreSQL Only
|
|
@ -0,0 +1,27 @@
|
|||
SELECT register_migration_script('202211180700_IDEMPIERE-5481.sql') FROM dual;
|
||||
|
||||
CREATE OR REPLACE FUNCTION trunc(datetime TIMESTAMP WITHOUT TIME ZONE, format varchar)
|
||||
RETURNS DATE AS $$
|
||||
BEGIN
|
||||
IF format = 'Q' THEN
|
||||
RETURN CAST(DATE_Trunc('quarter',datetime) as DATE);
|
||||
ELSIF format = 'Y' or format = 'YEAR' THEN
|
||||
RETURN CAST(DATE_Trunc('year',datetime) as DATE);
|
||||
ELSIF format = 'MM' or format = 'MONTH' THEN
|
||||
RETURN CAST(DATE_Trunc('month',datetime) as DATE);
|
||||
ELSIF format = 'DD' THEN
|
||||
RETURN CAST(DATE_Trunc('day',datetime) as DATE);
|
||||
ELSIF format = 'DY' THEN
|
||||
RETURN CAST(DATE_Trunc('day',datetime) as DATE);
|
||||
ELSE
|
||||
RETURN CAST(datetime AS DATE);
|
||||
END IF;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
||||
|
||||
CREATE OR REPLACE FUNCTION trunc(datetime TIMESTAMP WITH TIME ZONE, format varchar)
|
||||
RETURNS DATE AS $$
|
||||
BEGIN
|
||||
RETURN trunc(cast(datetime as timestamp without time zone), format);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
Loading…
Reference in New Issue