从数据库选择日期时,我想在数据库中的created_at日期中添加5:30

时间:2019-01-10 12:04:38

标签: mysql

我的Sql服务器存在于UTC中。当我选择时,我想获取添加了+5:30的DATE。

select cl.ChangeStatus,cl.created_at from LogTable cl join  Table t on cl.Id=t.ID;


ChangeStatus     created_at
----------------------------------
submitted   2019-01-10 08:03:11
sent        2019-01-10 08:06:55
sent        2019-01-10 08:08:14
sent        2019-01-10 08:09:03
complete    2019-01-10 08:09:54 

ChangeStatus   created_at
--------------------------------
submitted   2019-01-10 12:33:11
sent        2019-01-10 12:36:55
sent        2019-01-10 12:38:14
sent        2019-01-10 12:39:03
complete    2019-01-10 12:39:54

1 个答案:

答案 0 :(得分:0)

以下查询应该可以解决问题:

select
cl.ChangeStatus,
Todatetimeoffset(cl.created_at, '+5:30') as created_at
from LogTable cl
join  Table t on cl.Id=t.ID;