PLab
PLab

Reputation: 305

mysql compare 2 dates

I'm absolute noob in Java and Mysql. Have an assignment to make where user need to login and register. All code been done. But there is one little part where the user's login should expire in 6 month. I'm trying to accomplish it by using SELECT DATEDIFF(month,'2014-06-05','2014-08-05') AS DiffDate. I can track user's registry date but with the second date I'm a bit stumped. How can I track the current time of user login. Any suggestions. Thank you.

Upvotes: 1

Views: 214

Answers (1)

sagi
sagi

Reputation: 40481

You can use MySQL NOW() :

SELECT DATEDIFF(month,'2014-06-05',NOW()) AS DiffDate

Upvotes: 1

Related Questions