将Postgresql中的“带时区的时间”转换为“带时区的时间戳”

将Postgresql中的“带时区的时间”转换为“带时区的时间戳”,postgresql,Postgresql,我必须将一个表列从带有时区的time更改为带有时区的timestamp 我试着 alter table mytable alter column date type timestamp with time zone using date::timestamp with time zone 但是我得到一个错误,postgres不能自动转换这些类型。 我该怎么做 您可以指定使用null作为转换机制,以空值开始: alter table mytable alter column date typ

我必须将一个表列从带有时区的time更改为带有时区的timestamp

我试着

alter table mytable
alter column date type timestamp with time zone using date::timestamp with time zone
但是我得到一个错误,postgres不能自动转换这些类型。 我该怎么做

您可以指定使用null作为转换机制,以空值开始:

alter table mytable
  alter column date type timestamp with time zone
  using null;

@翼豹非常感谢你们; 因为时间泄露了日期,所以可以使用固定日期进行转换:

alter table mytable
alter column date type timestamp with time zone using date('20140101') + date;

所以我必须先截断我的表?是否有方法转换此列?@0bmis:无需截断行,但要进行转换,您必须提供自己的方法。时间不包含足够的信息来制作时间戳,因为它缺少日期,postgres无法发明这些信息。或