Have a table "user_order" with columns "user_id", "code" (character varying) and created_date_key (integer). I am trying to write a query which displays all records for code 26 and date greater that '12-5-2013 23:59:59'.
Select *
from user_order
where code like 26 ::text
and to_date(created_date_key ::text, 'YYYY-MM-DD') > to_date ('12-5-2013 23:59:59' ::text, 'YYYY-MM-DD')
ERROR: date format not recognized.
integer?to_date()converts a string (varchar,text) to a date. You cannot pass it an integer. Think about it: how could an integer even when casted to a string possibly have the format'YYYY-MM-DD'