MySQL Check Time Duration Passed?
MySQL Time Duration |
You may want to check whether a particular date has passed using start date, time duration and current date when the target date is not physically stored.
For clarity, consider a db table schema as follows.
For clarity, consider a db table schema as follows.
+-----------+--------------------------+------------------+ | event_id | start_time | duration_seconds | +-----------+--------------------------+------------------+ | 005 |'2014-10-1 12:13:08' | 86400 | +-----------+--------------------------+------------------+
Here `duration_seconds` is stored using integers. If TIME is used, there 's a limit for 24 hrs.
If you want to get only adverts that have not expired, you will run a query like this.
SELECT * FROM `events` WHERE TIME_TO_SEC(timediff(now(),start_time))<=`duration_seconds`;
0 comments: