![](/img/trans.png)
[英]What should the type of parameter be in Java when it is a “timestamp without time zone” in postgresql?
[英]PostgreSQL Parameter error (timestamp with time zone, timestamp without time zone)
我得到一个错误
Caused by: org.postgresql.util.PSQLException: ERROR: function months_between(timestamp with time zone, timestamp without time zone) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 310
我已经找到这个错误的原因是因为参数不匹配 => (timestamp without time zone, timestamp without time zone)
TRUNC(MONTHS_BETWEEN (date_trunc('day', now()), people.original_date_of_hire) / 12) masa_bekerja_year, ");
那么,如何将这个语法参数与这个正确的参数匹配 => (timestamp without timezone, timestamp without timezone)? 我需要匹配这个,因为我的框架使用这个参数格式并且我不允许更改框架。
强制CAST
:
TRUNC(MONTHS_BETWEEN (date_trunc('day', now())::timestamp, people.original_date_of_hire::timestamp) / 12) masa_bekerja_year, ");
请注意,执行此操作时可能会发生时区转换。 有关详细信息,请参阅以下部分:
https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-TIMEZONES
8.5.1.3。 时间戳
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.