Rat32 Posted April 9, 2016 Share Posted April 9, 2016 How I can compare the date? I have in MYSQL date for example "12-12-2015 13:34" and i want to check whether it's been 30 minutes. Link to comment
Rat32 Posted April 9, 2016 Author Share Posted April 9, 2016 How I can compare the date? I have in MYSQL date for example "12-12-2015 13:34" and i want to check whether it's been 30 minutes. Link to comment
Noki Posted April 9, 2016 Share Posted April 9, 2016 I would recommend using Unix timestamps in the future. They are much easier to compare in both Lua and MySQL. You will have to use MySQL's `STR_TO_DATE` function to convert your date into YYYY-MM-DD HH:MM:SS format, then convert that into a timestamp using `UNIX_TIMESTAMP` (with your previous date conversion as an argument). Then you can compare that with `UNIX_TIMESTAMP()` (note the lack of arguments), which is the current Unix timestamp. Quite tedious to be honest. Something like this: dbQuery(db, "SELECT `column1` FROM `table` WHERE UNIX_TIMESTAMP() - UNIX_TIMESTAMP(STR_TO_DATE(`column2`, '%Y %m %d %h:%i%p')) >= 32") Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now