SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


pass through query from access to sql-how can I select all records witha date greater than a fixed...


pass through query from access to sql-how can I select all records witha date greater than a fixed date

Author
Message
pauloliver
pauloliver
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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
Eugene Elutin
Eugene Elutin
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4972 Visits: 5478

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!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
pauloliver
pauloliver
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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 :-) :-D

Regards

Paul
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18327 Visits: 20413
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.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search