Results 1 to 2 of 2

Thread: getting different results with dates

  1. #1
    Join Date
    Apr 2009
    Posts
    1

    getting different results with dates

    m using ms sql server 2005

    when i fire query

    select * from .............
    .......................
    .......................
    and convert(varchar,login_date,101) = '03/24/2009'

    for the dates from '03/24/2009' to 04/10/2009

    ie i fire explicit query for each date
    and add all the results , then count is 107

    but if i fire query

    select * from .............
    .......................
    .......................
    and convert(varchar,login_date,101) >= '03/24/2009'
    and convert(varchar,login_date,101) <= '04/10/2009'

    i get only 41 results

    why the two query results differ so much ,
    the results should be same

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Do you have DISTINCT anywhere in SELECT?.

    You are converting date to VARCHAR, you may want to do it other way round, converting literal string to compare with login_date.

Posting Permissions

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