Forum Moderators: open

Message Too Old, No Replies

SQL Statement a little off

         

hal12b

7:23 pm on Jul 9, 2010 (gmt 0)

10+ Year Member



I am querying the database and outputting results onto my ASP.net page.

This is the query --> SELECT * FROM tblsometablename t1 where t1.collegeID=@collegeID and t1.DateCreated >= '3/20/2005' and t1.DateCreated <= '7/8/2010' order by t1.DateCreated desc, t1.StudentsLastName, t1.StudentsFirstName asc

The problem is the ending date. In this case it is 7/8/2010, but does not include 7/8/2010, it only shows results up to 7/7/2010. It always seems to be one day behind. Any ideas?

LifeinAsia

7:45 pm on Jul 9, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



My guess is that DateCreated field also has a time component. Just change the last part to t1.DateCreated < '7/9/2010' and you should be good to go.

hal12b

1:19 am on Jul 10, 2010 (gmt 0)

10+ Year Member



You are correct, there is a time component in the field in the database, but the user chooses a date from a drop down field to get 7/9/2010. Do I need to add one day to their selection?

LifeinAsia

3:27 pm on Jul 10, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Correct.