I have a very awful table structure that I have to deal with. This is in an ERP and I can't change the tables...yes I know how completely horrible this is. This system stores dates and times in separate columns. This in itself isn't so bad but they are always stored as numerics. This causes some very ugly code to turn this horrible design into a datetime value that is actually usable. I have come up with a couple of ways of turning into a datetime but I am looking for other ideas in case somebody comes up with a better idea.Here is my table and data. The first two columns are the Date and Time values stored as numerics. The last column is the datetime I need this to be.[code]CREATE TABLE #Something( VHRGDT numeric(8, 0) NOT NULL, VHRGTM numeric(6, 0) NOT NULL, DesiredDateTimeValue datetime) insert #Somethingselect 20150817, 134818, '2015-08-17 13:48:18.000' union allselect 20150818, 71406, '2015-08-18 07:14:06.000' union allselect 20150818, 141636, '2015-08-18 14:16:36.000' union allselect 20150819, 74938, '2015-08-19 07:49:38.000'select *from #Something[/code]Everything I have come up with is a mess of cast and stuff basically turning this mess into a string that can ultimately be cast as a datetime. Maybe some fresh eyes on this will come up with something better.
↧