Go to DotNetFunda.com
 Online : 1324 |  Welcome, Guest!   Login
 
Home > Forums > Sql Server > how to convert string of date-time to datetime format ...

Sql Server Forum



how to convert string of date-time to datetime format

Author: Abhi_patil | Posted on: 7/10/2009 | Category: Sql Server | Views: 3465 | Level: Starter | Status: [Member]

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..


Reply

Found interesting? Add this to:

| More

 Responses

Bravi  
Posted on: 7/13/2009 1:26:18 AM
Level: Starter | Status: [Member] | Reply

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, please login to Mark As Answer, if this helps | Alert Moderator 

PandianS  
Posted on: 7/13/2009 1:51:28 AM
Level: Bronze | Status: [Member] | Reply

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

Regards

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

Latest Posts

More ... 

 Write New Post


Advertisement

About Us | The Team | Advertise | Contact Us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 9/3/2010 4:00:04 AM