Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 search with date in different format

Author  Topic 

tpiazza55
Posting Yak Master

162 Posts

Posted - 2012-06-04 : 18:11:54
i am getting passed a date in ddmmyyyy format

how do i search in a where clause where the column is in mmddyyyy

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-06-04 : 18:31:55
You can use SET DATEFORMAT, but the data should be sent in an unambiguous format. Fix the source data and make your code easier.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tpiazza55
Posting Yak Master

162 Posts

Posted - 2012-06-04 : 18:48:46
have no control over the source data -- it comes as it comes

just need a way to convert ddmmyyyy into mm/dd/yyyy

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-06-04 : 18:52:46
Use SET DATEFORMAT dmy.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-06-05 : 05:17:34
Also read this post
http://beyondrelational.com/modules/2/blogs/70/posts/10898/understanding-datetime-column-part-ii.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -