I have a date field and a time field that I would like to combine in to a new datetime field.
Using MS SQL-Server
They are currently formatted like:
date: 2019-06-25 00:00:00.0000000
time: 0001-01-01 09:09:31.0000000
both fields are NVARCHAR(MAX)
I would like the end result to be:
20190625090931
How would I go about doing this?
date
will always have a zero component for the time, andtime
always has a "zero" (i.e.0001-01-01
) component for the date? Manipulating the strings so the result can be converted is simpler than adding "arbitrary" values (i.e.SELECT CONVERT(DATETIME2, LEFT('2019-06-25 00:00:00.0000000', 11) + RIGHT('0001-01-01 09:09:31.0000000', 16))
can then beFORMAT
ted further, or better yet, actually stored in a column).