Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error function to_date(timestamp without time zone, unknown) does not exist

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.

like image 959
Surya Prakash Tumma Avatar asked Nov 13 '13 07:11

Surya Prakash Tumma


People also ask

Why can't I generate date series with timestamp without time zone?

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);

Is it possible to use trunc without time zone?

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.

Is there a function to convert timestamp to text?

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!


2 Answers

Three year later. You can cast

SELECT     to_date(cast(createddate as TEXT),'YYYY-MM-DD')  FROM       product_trainings; 
like image 114
Wilson Carlos Avatar answered Oct 17 '22 22:10

Wilson Carlos


And even neater:

SELECT to_date(createddate::TEXT,'YYYY-MM-DD')  FROM product_trainings; 
like image 20
Zon Avatar answered Oct 18 '22 00:10

Zon