|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, January 24, 2013 10:26 AM
Points: 2,
Visits: 2
|
|
Hi I am an absolute 'noob' when it comes to t-sql however because of an issue we are haing in extracting some data from an sql database I need to to run a pass through query and use the following in my criteria
WHERE orderdate >= 31/10/2010
I have tried the following without success
WHERE orderdate >= '31/10/2010'
in access I would just use
WHERE orderdate >= #31/10/2010#
any help would be greatly appreciated as I say I am a complete novice but I am willing to try
Regards
Paul
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 10:59 AM
Points: 2,525,
Visits: 4,324
|
|
I have tried the following without success
WHERE orderdate >= '31/10/2010'
Any error returned?
Anyway, whenever you are using date strings, make sure they are in non-locale dependent format. Best is ISO: YYYY-MM-DD (YYYYMMDD will also work) , or you can use words for month: '31 Oct 2010'
so:
WHERE orderdate >= '20101031'
or
WHERE orderdate >= '31 Oct 2010'
_____________________________________________ "The only true wisdom is in knowing you know nothing" "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!" (So many miracle inventions provided by MS to us...)
How to post your question to get the best and quick help
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, January 24, 2013 10:26 AM
Points: 2,
Visits: 2
|
|
ssCrazy,
Thanks for the reply, I have used
WHERE orderdate >= '31 Oct 2010'
and it has worked fine, thank you for the help 
Regards
Paul
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Yesterday @ 5:12 AM
Points: 4,226,
Visits: 9,458
|
|
I second Eugene (whose middle name may well be ssCrazy ) - best practice is to use YYYY-MM-DD format when specifying dates in T-SQL:
WHERE orderdate >= '2010-10-31'
____________________________________________________________________________________________
Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|