October 21, 2008 at 8:30 am
Hi All,
I need to update just the time portion of a datetime column COLUMN_A (2008-10-20 10:05:03:123) from another column COLUMN_B that has just time data stored as VARCHAR (11:06:04:456)
I can't quite seem to get the data converted quite ..... any tips ?
October 21, 2008 at 8:46 am
Like this:
select CAST(convert(varchar(10), COLUMN_A, 121) +' '+ Right(convert(varchar(24), COLUMN_B, 121),12) as DATETIME)
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
October 21, 2008 at 8:54 am
Bingo ! Thanks a lot !
October 21, 2008 at 9:07 am
Glad I could help!
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
October 21, 2008 at 9:34 am
This would also do what you want:
select dateadd(dd,datediff(dd,0,COLUMN_A),0)+COLUMN_B
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply