获取错误函数to_date(没有时区的时间戳,未知)不存在

Sur*_*mma 9 sql database postgresql jdbc

最近我将我的postgres从8.2迁移到8.4.当我运行我的应用程序并尝试登录时,我收到这些错误

 ERROR [JDBCExceptionReporter] ERROR: function to_date(timestamp without time zone, unknown) does not exist
Run Code Online (Sandbox Code Playgroud)

我通过执行这些to_date函数检查了我的postgres

SELECT  to_date(createddate,'YYYY-MM-DD') FROM  product_trainings;
Run Code Online (Sandbox Code Playgroud)

它给我错误函数to_date不存在

当我在postgres 8.2中执行相同的查询时,我没有收到错误

请帮我解决这些问题.

小智 13

三年后.你可以施展

SELECT
    to_date(cast(createddate as TEXT),'YYYY-MM-DD') 
FROM  
    product_trainings;
Run Code Online (Sandbox Code Playgroud)


Zon*_*Zon 12

甚至更整洁:

SELECT to_date(createddate::TEXT,'YYYY-MM-DD') 
FROM product_trainings;
Run Code Online (Sandbox Code Playgroud)


Fas*_*ngy 6

它似乎只需要从时间戳到文本的转换,因为函数定义是:to_date(text,text).

也许在8.2中,已经预定义了从时间戳到文本的转换.

http://www.postgresql.org/docs/8.4/static/functions-formatting.html