更新表中给定年份的所有时间戳

时间:2014-10-16 10:29:23

标签: sql postgresql

我想更新我的表,并在每年的2010年时间戳上添加4年。我使用的是postgresql。

x    |  y     

c    | 2010-05-08 16:23:00
d    | 2011-01-01 01:23:45

期望的结果:

x    |  y    

c    | 2014-05-08 16:23:00 
d    | 2011-01-01 01:23:45

谢谢。

1 个答案:

答案 0 :(得分:3)

update the_table
   set y = y + interval '4' year
where extract(year from y) = 2010;
相关问题