Feb 10, 2017 03:20 AM|wavemaster|LINK
I have a rather nasty piece of t-script that produces this string: 2017-02-10 02:30:00.0000000
CONVERT(DATETIME2, (CAST(CAST(getdate() AS date) AS varchar(100)) + ' ' + CAST(CAST(schDateTimeEnd AS time) AS varchar(100))), 21)
It consists of two pieces:
a. the date of GETDATE() (the first CAST) then another CAST to string
b. the time from schDateTimeEnd (the first CAST) then another CAST to string
Those pieces concatenated to a string and turned into a datetime.
Is there a more elegant way to do this?