Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

pass through query from access to sql-how can I select all records witha date greater than a fixed date Expand / Collapse
Author
Message
Posted Thursday, January 24, 2013 8:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #1411165
Posted Thursday, January 24, 2013 9:56 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 3:45 AM
Points: 2,873, Visits: 5,188

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
Post #1411234
Posted Thursday, January 24, 2013 10:26 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #1411253
Posted Monday, January 28, 2013 8:32 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 5:15 PM
Points: 5,245, Visits: 12,163
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1412470
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse