Assuming the datatype item_valid_from
and item_valid_to
is DATE, TIMESTAMP, etc, then you have your operators backwards. Think of the time as seconds since 1970, since this is how it is stored in unix time. That means that item_valid_from
is going to be smaller than item_valid_to
, and you want it to display when today is somewhere between them. You want the item_valid_from
to be less than or equal to now, and the item_valid_to
to be greater than now (not in the past).
SELECT *
FROM tbl1
WHERE item_valid_from <= CURDATE() AND item_valid_to > CURDATE()
See this SQL Fiddle for an example, only 2-4 are valid and show up in the results being valid from a date in the past and expiring on a date in the future.