Results 1 to 3 of 3

Thread: date selection

  1. #1
    Join Date
    Sep 2002
    Location
    Amsterdam
    Posts
    53

    date selection

    When I query a table with a datetype field I get the date in european format (dd-mm-yy(yy)). However, whenever I try to make a selection using a comparison string in the WHERE clause like '22-09-2002' I get no results. When I change the string in the USA format (09-22-2002) it gives the expected results. Which config/installation setting governs this behaviour?

    Thnx

  2. #2
    Join Date
    Sep 2002
    Location
    Moscow, Russia
    Posts
    1

    date selection

    In situations like this you should use
    'convert' function in WHERE clause
    (See the description in SQL BOL).
    If you write
    convert(datetime, '22-09-2002', 105)
    instead of
    '22-09-2002'
    you'll get the expected result, so you
    may not be aware about the current date format settings.

  3. #3
    Join Date
    Sep 2002
    Location
    Amsterdam
    Posts
    53

    Re: date selection

    Originally posted by Oleg Zernov
    In situations like this you should use
    'convert' function in WHERE clause
    (See the description in SQL BOL).
    If you write
    convert(datetime, '22-09-2002', 105)
    instead of
    '22-09-2002'
    you'll get the expected result, so you
    may not be aware about the current date format settings.

    Thanks Oleg.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •