in reply to Comparing different timestamp formats
Hi, I wonder how your MySQL timestamp has that format? By default MySQL timestamps look like '2018-10-24 17:08:00'.
As ++haukex suggested, the best thing to do is let the DB do that query: after all, that's what it's for. You should easily be able to create an SQL query to fetch the records you're interested in with the DBI.
For comparison, here's the database table I am working on right now:
[localhost]:mysql> explain account; +---------------+------------------+------+-----+-------------------+- +----------------------------+ | Field | Type | Null | Key | Default | +Extra | +---------------+------------------+------+-----+-------------------+- +----------------------------+ [redacted] | created_on | timestamp | NO | | CURRENT_TIMESTAMP | + | | modified_on | timestamp | NO | | CURRENT_TIMESTAMP | +on update CURRENT_TIMESTAMP | +---------------+------------------+------+-----+-------------------+- +----------------------------+ 9 rows in set (0.00 sec) [localhost]:mysql> select count(account_id) from account; +-------------------+ | count(account_id) | +-------------------+ | 66 | +-------------------+ 1 row in set (0.00 sec) [localhost]:mysql> select count(account_id) from account where datedif +f(now(), modified_on) >= 1; +-------------------+ | count(account_id) | +-------------------+ | 42 | +-------------------+ 1 row in set (0.00 sec)
"I'm trying to tell if a transaction occurred more than 1 day ago."
Note that the granularity of date_diff is one day, so for your query you probably want everything that's not 0 days difference.
Hope this helps!
|
|---|