MikeMarsian
MikeMarsian

Reputation: 638

How to convert Date to DateTime in PostgreSQL?

I'm trying to make the following work in PostgreSQL:

SELECT * FROM purchases WHERE CONVERT(expiration_date) < '2013-03-21 13:14:00'

Where CONVERT is some method that would convert Date to DateTime. Any idea how to do this?

Upvotes: 11

Views: 42753

Answers (1)

Jakub Kania
Jakub Kania

Reputation: 16487

There is no DateTime type in PostgreSQL, there's timestamp.

To convert simply do expiration_date::timestamp but I think it should work without conversion. WHERE expiration_date < '2013-03-21 13:14:00' should be valid.

Upvotes: 24

Related Questions