Jump to content

Date comparing


Rat32

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...