October 23, 2009 at 8:46 am
I have carchar datatype in the following format
'09-06-2005 00:00:00'
is there a way to convert this value to datetime type as I need to calculate the datediff between the current date and the above date.
Thanks for you help.
"More Green More Oxygen !! Plant a tree today"
October 23, 2009 at 9:52 am
CAST and CONVERT http://msdn.microsoft.com/en-us/library/ms187928%28SQL.90%29.aspx
October 23, 2009 at 8:41 pm
Minaz Amin (10/23/2009)
I have carchar datatype in the following format'09-06-2005 00:00:00'
is there a way to convert this value to datetime type as I need to calculate the datediff between the current date and the above date.
Thanks for you help.
No conversion necessary... an implit conversion will take place in both DATEDIFF and DATEADD.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 24, 2009 at 11:22 am
Thank you all for helping me out. code is absolutly running fine.:-D
"More Green More Oxygen !! Plant a tree today"
October 25, 2009 at 10:37 am
what about this?
select datediff(d,getdate(),convert (datetime,'09-06-2005 00:00:00',101))
Kindest Regards,
Paarthasarathy
Microsoft Certified Technology Specialist
http://paarthasarathyk.blogspot.com
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply