mysql - Get records between 2 dates but sometimes they can be null -
i have 2 dates in database: start_date , end_date(type date). end_date can null, means if start_date <= current date need record well. added condition both dates set now() >= of.start_date , now() < of.end_date. how can records have end_date = null (in same query), means active if start_date <= now() (they won't start in future)? there possibility neither start_date , end_date set. in case need records well. how can achieve in 1 query?
use coalesce() or put null logic in explicitly:
where now() >= of.start_date , (of.end_date >= now() or of.end_date null)
Comments
Post a Comment