January 24, 2013 at 8:25 am
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
January 24, 2013 at 9:56 am
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'
January 24, 2013 at 10:26 am
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
January 28, 2013 at 8:32 am
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'
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply