3 ms·
No, the code casts to "timestamp without time zone" before running date_trunc so it is immutable. For example: CREATE OR REPLACE FUNCTION gd_day(timestamptz
by jeltz 13y ago
No, the code casts to "timestamp without time zone" before running date_trunc so it is immutable.
For example:
CREATE OR REPLACE FUNCTION gd_day(timestamptz, text)
RETURNS timestamptz AS
$$
SELECT DATE_TRUNC('day', $1 AT TIME ZONE $2) AT TIME ZONE $2;
$$
LANGUAGE SQL;
EDIT: The reason that some time functions in PostgreSQL are not immutable is that they are affected by the current time zone setting of the session.