I am working with a Postgres table that has a field named first_contact_date where it is of type date. I am using the the mm/dd/yyyy representation of a date.
My query works correctly as written but it orders literally by month.
SELECT first_contact_date
FROM schema.table
ORDER BY first_contact_date
For example "10/3/2016" would go after "1/2/2017", even though in a date sense, it should be "1/2/2017" that goes after "10/3/2016".
I have looked at
- How to find the earliest and latest date from a database, but its too vague and I am using an order by already.
- SQL ordering by earliest date in group, but I am using a different format.
- How do I return the record with the earliest date?, ditto with number 2
and
- PostgreSQL query where date oldest, but this limits it to one year
How to I structure the query so that the earliest date from a calendar perspective is returned?
order by first_contact_date::dateError message: invalid input syntax for type date: ""implies that your column is not of type date. Maybe you should add your table definition plus some data?