how to convert string of date-time to datetime format

Posted by Abhi_patil under Sql Server on 7/10/2009 | Views : 20677 | Status : [Member] | Replies : 2
i have table report contains colume report_date having datatype nvarchar..

but now i want to get report before specific date..so how i can get that report correctly..

ex. i want to get report <'7/8/2009 10:10:50 AM'
how i can write query for that...

thanks..




Responses

Posted by: Bravi on: 7/13/2009 [Member] Starter

Up
0
Down
I hope this code will useful for you try this

Convert(datetime,report_date)<Convert(datetime,'7/8/2009 10:10:50 AM' )

After writing query in where conditon write like this so you can get records..



Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: PandianS on: 7/13/2009 [Member] [MVP] Silver

Up
0
Down
select Col1,Col2 from report where CAST(Report_Date AS DATETIME) < '7/8/2009 10:10:50 AM'

Regards

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response