Forum Moderators: open

Message Too Old, No Replies

BETWEEN giving me grief

Between with dates... :-(

         

aquanutz

1:48 pm on Sep 15, 2006 (gmt 0)

10+ Year Member



Alright, I have a date from my calendar that I am trying to see if it is within a rang of dates in a table in MySQL. I am using BETWEEN (as per my thread yesterday) but it is bringing back every entry in the table and not just the ones that match the BETWEEN statement.

here is what I have (Using dates instead of variables to make it easier):

select * from intersessionDates where DATE '2006-12-16' between DATE '2006-12-15' and DATE '2007-01-07';

and it brings back:
+-----+------------+------------+
¦ num ¦ startDate ¦ endDate ¦
+-----+------------+------------+
¦ 1 ¦ 2006-08-04 ¦ 2006-08-20 ¦
¦ 2 ¦ 2006-12-15 ¦ 2007-01-07 ¦
+-----+------------+------------+

It should only bring back the Second tuple...

I've tried it with and without the 'DATE' on there and I've tried putting times on the end too, nothing works... Any thoughts?

thanks.

aquanutz

2:43 pm on Sep 15, 2006 (gmt 0)

10+ Year Member



nevermind, i'm a moron. figured it out. i needed "where '2006-12-16' between startDate and endDate" and not the actual dates themselves.. not sure how I overlooked that.

coopster

2:57 pm on Sep 15, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



We all do so don't be so hard on yourself. And welcome to WebmasterWorld ;)