I have a table in SQL Server where sometimes the DATE
column gets wrong date from import procedure and it gets set to 22th of Aug. 2099, while time part of DATE
column is OK.
I can see all those columns with this query:
SELECT
[ImportId], [Date], [PickupId],
[Quantity], [Temp], [ImportDate]
FROM
[DatabaseName].[dbo].[Imports]
WHERE
Date >= Convert(datetime, '2018-12-31' )
So, DATE column has wrong date and correct time, like here:
2099-08-22 03:10:18.000
And IMPORTDATE
column has correct date, but zeroed out time part, like here:
2017-03-22 00:00:00.000
I would like to combine date part from IMPORTDATE and time part of DATE column, both together to become new DATE column:
2099-08-22 03:10:18.000 (time part from DATE column)
2017-03-22 00:00:00.000 (date part from IMPORTDATE column)
2017-03-22 03:10:18.000 (combined will be new DATE column)
So this record:
ImportId Date PickupId Quantity Temp ImportDate
74256 2099-08-22 03:10:18.000 111111 2356 3,8 2016-04-12 00:00:00.000
Would become this:
ImportId Date PickupId Quantity Temp ImportDate
74256 2016-04-12 03:10:18.000 111111 2356 3,8 2016-04-12 00:00:00.000
Anyone willing to construct proper SQL query to do this for me?