Dro1n2
Dro1n2

Reputation: 3833

mysql date compare

In one of my mysql tables I have columns start stop. For example the value of start is 2011-01-21 and the value of stop is 2011-03-23. Assuming today is 2011-03-10 how to determine that "today" is between start and stop period ?

Upvotes: 0

Views: 683

Answers (3)

benhowdle89
benhowdle89

Reputation: 37464

Hmmm bit ambiguous but you could store today date in a variable and do a "select start, stop from table" then in a PHP for loop you could evaluate whether your today variable is between the two date values?

Upvotes: 0

Björn
Björn

Reputation: 29381

select
    *
from
   `tbl`
where
   now() between `the_start_date` and `the_end_date`

Upvotes: 0

Haim Evgi
Haim Evgi

Reputation: 125476

select * from mytable where CURDATE() between start and stop 

Upvotes: 5

Related Questions