Reputation: 2560
I have a column Date which is Datetime type. And I have an nvarchar column with the time inside. For example:
Date(datetime) Time(nvarchar)
----------- ----------
2010-06-08 00:00:00.000 17:30
How can I concatenate them to 2010-06-08 17:30:00.000 as a datetime object?
Upvotes: 2
Views: 122
Reputation: 121922
Try this one (it's works on version 2005 and higher) -
DECLARE
@Date DATETIME
, @Time NVARCHAR(5)
SELECT
@Date = '2010-06-08 00:00:00.000'
, @Time = '17:30'
SELECT @Date + @Time
Output:
2010-06-08 17:30:00.000
Upvotes: 6
Reputation: 1057
Try this, I don't have SQL server 2005 installed on my machine here. I only have oracle. But I found this in one of my TSQL snippets folder.
SELECT theDate + CAST(theTime AS TIME);
Upvotes: 0