Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003
    Posts
    3

    Unanswered: Date Field problem

    Hi All,

    I have the following query , it is getting values of 6th months also
    Actually i want only values between the dates....
    nt_date is datetime field

    select CONVERT(varchar(10), nt_date, 103) from empdate
    where CONVERT(varchar(10), nt_date, 103) between '01/05/2003' and '10/05/2003'

    my idea of the above query is that it has to display only
    records between 01/05 to 10/05

    Thanks

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you should do the WHERE comparison in date format, not in string format --
    Code:
    select CONVERT(varchar(10), nt_date, 103) 
      from empdate
     where nt_date between '2003-05-01' and '2003-05-10'
    the reason yours wasn't working is because using a string comparison, '09/03/1937' would fall between '01/05/2003' and '10/05/2003'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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