Robert Ross Robert Ross - 1 year ago 59
MySQL Question

Comparing two datetime fields in a table and displaying a record in another table based on the result

I am trying to compare the to datetime fields in my

table so if the difference between the dates is bigger then 31 days I can get the names from the
table of the borrowers, who delayed the return of their book. I am not allowed to use triggers or stored procedures for the task, so I am aiming to do it in another way, but I don't even know where to start.
I'd appreciate any tips on how to do that.

Here is the part of my database that is used for the task.

enter image description here

Answer Source

This sentence should do the work:

    left join borrower
        on load.Borrower_idBorrowerPK = borrower.idBorrowerPK
    DATEDIFF(CURDATE(), loan.dateBorrowed) >= 31
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download