将日期和时间字段组合到一个新列 [英] Combining date and time fields to one new column
本文介绍了将日期和时间字段组合到一个新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两列日期和时间:
DateId
20170424
Timeid:
1820
i需要将这两个字段添加到新列中,结果如下:2017-04-24 18:20:00 < br $> b $ b
我尝试过的事情:
i尝试了但没有工作,需要将这些添加到新字段
I have two columns date and time:
DateId
20170424
Timeid:
1820
i need to add these two fields to a new column and the result to be like : 2017-04-24 18:20:00
What I have tried:
i have tried but not working, and need to add those into a new field
推荐答案
I got the solution:
convert(datetime,(
Cast((Left(fwo.Date_Id,4) + '-' + SUBSTRING(cast(fwo.Date_Id as varchar(20)),5,2) + '-' + right(fwo.Date_Id,2)) + ' '
+ (case when len(fwo.Time_Id) < 4 then LEFT(fwo.Time_Id,1) else LEFT(fwo.Time_Id,2) END + ':' + RIGHT(fwo.Time_Id,2)) as datetime)),120) as[Estimated Date Time]
这篇关于将日期和时间字段组合到一个新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文