I have multiple database servers I'm querying with a query that compares an expiration column with now(). The problem is that one of the servers' expiration column is a timestamp with time zone, and all the rest are simply date. I can't change this because I don't have admin access, and in fact I'm only querying the view. Postgres is fairly new to me, so I don't really understand how the dates and times work with each other.
When I try and query the server with timestamp with time zone by casting the timestamp as a date:
...
WHERE
(
status_code = '30000'
OR status_code = '30005'
)
AND CAST(expiration AS DATE) > now()
It works, but using the same query on the servers where expiration is already a date fails:
[Err] ERROR: invalid input syntax for type date: "No End Date"
Any help would be appreciated, I'd really rather not hard code an exception for this one DB server.
expirationis atimestampcolumn? Sounds like it's a convertion problem caused by theCASToperator – a_horse_with_no_name Apr 3 '12 at 21:46