public.last_day
Documentation | Pagila |
Schema | public |
Name | last_day |
Module | Functions |
Input/Output
Mode | Name | Data type | Description | |
---|---|---|---|---|
1 | OUT | Returns | date | Return the last day of the month for the given date. |
Return the last day of the month for the given date. | ||||
2 | IN | $1 | timestamp with time zone | The date or datetime value from which to extract the last day of the month |
The date or datetime value from which to extract the last day of the month |
Script
CREATE OR REPLACE FUNCTION public.last_day(timestamp with time zone) RETURNS date LANGUAGE sql IMMUTABLE STRICT AS $function$ SELECT CASE WHEN EXTRACT(MONTH FROM $1) = 12 THEN (((EXTRACT(YEAR FROM $1) + 1) operator(pg_catalog.||) '-01-01')::date - INTERVAL '1 day')::date ELSE ((EXTRACT(YEAR FROM $1) operator(pg_catalog.||) '-' operator(pg_catalog.||) (EXTRACT(MONTH FROM $1) + 1) operator(pg_catalog.||) '-01')::date - INTERVAL '1 day')::date END $function$ |
Exported: 2018-10-12 17:07, Last imported: 2018-08-06 09:25