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!


The way forward always starts with a minimal test.

In reply to Re: Comparing different timestamp formats by 1nickt
in thread Comparing different timestamp formats by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.