使用时区保存PostgreSQL日期

时间:2018-06-18 15:03:41

标签: sql postgresql

当我执行以下查询时,它会使用时区

更新日期字段
16:19:11 DEBUG:    Found object: name_of_the_object
16:19:11 ERROR:    Error: Failed to move the mouse
16:19:11 ERROR:    Exception type: RuntimeError
16:19:11 ERROR:    Exception message: Failed to move the mouse
16:19:11 ERROR:    Stack trace: path/my_squish_wrapper.py , Line : 170, Func.Name : mouse_move, Message : mouseMove(my_obj, x, y)']

当我查询时:

update person set hiredate='2018-06-18 23:59:59-04:00' where id=5684

我获得了hiredate的以下值:select * from person where id=5684 (在我的时区+5:30)

但我想以

执行查询
2018-06-19 09:29:59

并运行select查询,我将hiredate作为:update person set hiredate=now()::date + time '23:59:59-04:00' where id=5684

请帮助我如何

2 个答案:

答案 0 :(得分:2)

timetime without time zone的缩写。尝试

UPDATE person
       SET hiredate = now()::date + time with time zone '23:59:59-04:00'
       WHERE id = 5684;

答案 1 :(得分:-1)

我认为这就是你想要的

update person set hiredate= timestamp with   
time zone now()::date + time '23:59:59-04:00' 
where id=5684;