Recently i have migrated my postgres from 8.2 to 8.4. when I run my application and tried to login i am getting these error
ERROR [JDBCExceptionReporter] ERROR: function to_date(timestamp without time zone, unknown) does not exist
i had checked in my postgres by excecuting these to_date function
SELECT to_date(createddate,'YYYY-MM-DD') FROM product_trainings;
it is giving me error function to_date does not exist
when i execute the same query in postgres 8.2 i am not getting error
Please help me to resolve these issue.
I also get this same error when I try to generate a date series with timestamp without time zone This is because generate_series currently requires a step when the inputs are not int, bigint or numeric from the docs SELECT d FROM generate_series ( 'YESTERDAY'::date, 'TODAY'::date, '1 day' -- REQUIRED STEP ) AS gs (d);
function trunc (timestamp without time zone, "unknown") does not exist Hint: No function matches the given name and argument types. You may need to add explicit type casts. What did I do wrong in the query? Thanks! As the error says, that function doesn't exist.
It seems like all it needs is a conversion from timestamp to text as function definition is: to_date (text,text). Perhaps in 8.2 this conversion from timestamp to text was already predefined. Thanks for contributing an answer to Stack Overflow!
Three year later. You can cast
SELECT to_date(cast(createddate as TEXT),'YYYY-MM-DD') FROM product_trainings;
And even neater:
SELECT to_date(createddate::TEXT,'YYYY-MM-DD') FROM product_trainings;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With