[sql] How to extract year and month from date in PostgreSQL without using to_char() function?