locked
Add a Time column and a Date column together? RRS feed

  • Question

  • Hi,

    Please can someone help with. I am trying to create a new column containing a combination of two existing columns.

    Column 1 is datetime and column 2 is smallint

    Example

    2020-11-20 00:00:00.000            900

    2020-11-21 00:00:00.000             1700

    I want to create a new column which is a comb of Column 1 and 2

    End result:

    2020-11-20 09:00:00.000

    2020-11-21 09:00:00.000

    I tried myself with : SELECT

    CONVERT(datetime, CONVERT(varchar(10), Column2 / 100)+ ':' + CONVERT(varchar(10), Column2% 100))

    This gets a new column as a datetime, but doesn't contain the proper date.

    Any help appreciated.

    Thanks

    Wednesday, September 30, 2020 2:06 PM