I have a table called “Event”. A column has “duration”–which is…how long that event lasts.
What database type should this be? Integer? (in seconds)?
In the future, I will do statements such as:
If now() > event.duration THEN don't display the event.
In MySQL there is a column type called
TIMEwhich can be used to store durations:Note in particular that the limit is only 839 hours, so if you need more than that you might prefer to use an integer field instead.
If you want to fetch only events shorter than a certain duration you can do this with a WHERE clause. For example, to fetch only events that have lasted for less than 10 hours: