sql - How to combine separate Date and Time columns into DateTime? -


i have customer database include lmd(last modified date) data type date , lmt(last modified time) data type int. need create datetime lmd , lmt column. here rows,

lmd          lmt 2014-09-03  172351 

you might use divsion , modulo extract needed parts dateadd

declare @datefield date declare @timefield int  set @datefield='20140910' set @timefield=121314  select cast(@datefield datetime) + dateadd(hour,@timefield/10000,0) + dateadd(minute,@timefield/100 % 100,0)+ dateadd(second,@timefield % 100,0)   select cast(lmd datetime) + dateadd(hour,lmt/10000,0) + dateadd(minute,lmt/100 % 100,0)+ dateadd(second,lmt % 100,0), lmt, lmd mytable 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -