I have a table where I store "start" and "end" dates, and other various rows, e.g.:

s\_d = 2000-01-01

e\_d = 2000-05-17

I want to pull some rows from the table depending on whether or not the current date falls on or between the start and end dates, but I can't seem to get it working.

I use a static year (2000) because i'm honestly not sure how to go about comparing dates using just the month and day alone.

```
$q = "SELECT 
    xxx, 
    yyy,    
    c_d,
    e_d,
    DATE('2000-'.DATE('m').'-'.DATE('d')) AS c_d
    FROM mytable
    WHERE c_d >= s_d AND c_d <= e_d";

```

The above code doesn't work, i've tried casting, e.g.: CAST('datestuff' AS DATE), or using a php variable with no luck. I suck with date-related stuff.

My s\_d and e\_d rows are "DATE NOT NULL" fields, so i'm sure it has something to do with the c\_d (current date) I created.

**UPDATE (still testing):**

This seems to work well, some parts may be redundant (using date\_format on s\_d & e\_d), but it prevents me from messing something later on.

Using DATE\_FORMAT on MONTH/DAY(NOW()) will create a leading 0 to match the s\_d and e\_d stored in the table.

```
$q = "SELECT xxx
    , s_d
    , e_d
    FROM mytable
    WHERE DATE_FORMAT(CONCAT('2000', '-', MONTH(NOW()), '-', DAY(NOW())), '%Y-%m-%d') >= DATE_FORMAT(s_d, '%Y-%m-%d') 
    AND DATE_FORMAT(CONCAT('2000', '-', MONTH(NOW()), '-', DAY(NOW())), '%Y-%m-%d') <= DATE_FORMAT(e_d, '%Y-%m-%d')
    AND xxx = '$xxx'";

```