Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Posts
    115

    Unanswered: SELECT DATE problem SQL 2000

    I am runing this VIEW :

    SELECT users.id FROM users WHERE CONVERT(DATETIME, users.Inscription, 111) = CONVERT(DATETIME, '2006/02/14 12:00:00', 111)

    the datestyle 111 = yy/mm/dd

    I want to compare the dates without the times

    the view returns nothing when they are > 10 rows in the database for 2006/02/14

    how can i search on universal date yy/mm/dd ? or yyyy/mm/dd

    in the datestyle there is nothing for yyyy/mm/dd thats crazy !

    thank you for helping


    date styles : http://www.sqljunkies.com/Article/66...C7FD826E5.scuk

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Code:
    SELECT	users.id
    FROM	users
    WHERE	dateadd(day, datediff(day, 0, users.Inscription), 0) ='2006/02/14 12:00:00'
    or:
    Code:
    SELECT	users.id
    FROM	users
    WHERE	users.Inscription >='2006/02/14 12:00:00'
    	and users.Inscription < dateadd(day, 1, '2006/02/14 12:00:00')
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jun 2005
    Posts
    115
    but is it the only normal way to lookk for a date !!???

    i try :-(

    thank you

  4. #4
    Join Date
    Jun 2005
    Posts
    115
    it works in that way


    SELECT users.id
    FROM users
    WHERE (CONVERT(DATETIME, users.Inscription, 111) >= CONVERT(DATETIME, '2006/02/14 00:00:00', 111)) AND (CONVERT(DATETIME, users.Inscription, 111)
    <= CONVERT(DATETIME, '2006/02/15 00:00:00', 111))

    it doesnt work with BETWEEN it will be so praticle

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    BETWEEN works, but it's evaluation is inclusive, so you would have to adjust one time comparison to a single clock-tick before midnight.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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