Tutorial by Examples

You can convert a timestamp or interval value to a string with the to_char() function: SELECT to_char('2016-08-12 16:40:32'::timestamp, 'DD Mon YYYY HH:MI:SSPM'); This statement will produce the string "12 Aug 2016 04:40:32PM". The formatting string can be modified in many different wa...
You can select the last day of month. SELECT (date_trunc('MONTH', ('201608'||'01')::date) + INTERVAL '1 MONTH - 1 day')::DATE; 201608 is replaceable with a variable.
SELECT date_trunc('week', <>) AS "Week" , count(*) FROM <> GROUP BY 1 ORDER BY 1;

Page 1 of 1