Datetime issue

  • Hi I am sure I have seen this before but can't remember why it happens exactly.

    Basically I have a column which displays a datetime in the following format:

    2008-08-01 00:00:00.000

    however if I search for the date as shown I get 0 rows returned. If I query for the date in the following format I get the correct rows returned:

    2008-01-08

    Why is this happening?

  • This is down to to language (and hence date format) options.

    The OUTPUT of dates and assumptions as to valid INPUT forms are controllable separately.

    "set dateformat" will allow youto control valid input forms, but BY FAR the safest is to always use an unambiguos form when inputting dtaes, the simplest of whih is a quoted string in the form yyyymmdd - ie '20090928' for today.

    The problem you are seeing is that the form with hyphens can mean either yyyy-mm-dd or yyyy-dd-mm depending on the configuration options...

    Mike

  • Use cast operator for a particular format.

  • Pradyothana Shastry (9/28/2009)


    Use cast operator for a particular format.

    or convert 😀

    --------------------------------------------------------------------------------------
    [highlight]Recommended Articles on How to help us help you and[/highlight]
    [highlight]solve commonly asked questions[/highlight]

    Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden[/url]
    Managing Transaction Logs by Gail Shaw[/url]
    How to post Performance problems by Gail Shaw[/url]
    Help, my database is corrupt. Now what? by Gail Shaw[/url]

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply