Вопрос

I have a simple MySql DB with some logdata. I want get a forecast for events that repeats +-30min on a Weekday. eg: I compare 3 Events that match the criteria and give a alert.

And now the Question: What is the best method to compare the time? I can put mktime or date() via PHP into the DB or I do it direct with mysql.

Это было полезно?

Решение

What could be done on database level most certainly should be done there, considering performance.

SELECT * FROM tbl WHERE mytime >= DATE_SUB(NOW(), INTERVAL 30 MINUTE)

This will search everything that is at most 30 minutes ago and newer. Feel free to modify this query to fit your needs.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top