Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a db with some customers data. There I store their last login time as datetime.

I want to run a cron php script every min which will query mysqli for their last login datetime and if that was more than 20 mins in the past i will run some js popup etc (something like NOW() - last_login).

Anyway I am trying to query the db directly for that kind of users based on that 20 min time difference.

With php it's easy to filter results but I want to bring directly results from my mysql db without any intermediate process from php.

How can I accomplish this?

share|improve this question
    
Ok, i 've found the solution and i want to share it with you. "SELECT * FROM tbl_name WHERE dt_column < DATE_SUB(NOW(), INTERVAL 20 MINUTE)" This brings all entries were last login dt was more than 20 mins in the past. –  marios Jan 18 '13 at 19:28
    
You can add that as an answer (of your question). –  ypercube Jan 18 '13 at 20:24
add comment

1 Answer 1

Ok, i 've found the solution and i want to share it with you.

SELECT * FROM tbl_name WHERE dt_column < DATE_SUB(NOW(), INTERVAL 20 MINUTE)

This brings all entries were last login was more than 20 mins in the past.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.