I am supposed to select all the persons born in July (or 07). This did not work:
select * from people where date_trunc('month',dob)='07';
ERROR: invalid input syntax for type timestamp with time zone: “07”
LINE 1: …ct * from people where date_trunc(‘month’,dob)=’07’;
What is the right way?
gives you all people who where born in September, if the date of birth is stored in a timestamp table column called ‘dob’.
The second param is the date format pattern. All typical patterns should be supported.
E.g.:
would do the same.
look here for timestamp format patterns in Postgres: