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

  • 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

  • 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[/url]

  • 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

  • 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