How to extract year and month from date in PostgreSQL ?
Use this Command :
I know the order is no correct.but i know why it is wrong (at least until year 10000 comes around).
Use the date_trunc method to truncate off the day
Below is example command
SUM(amount) as sales,
date_trunc('month', created_at) as date
group by date
order by date DESC;