Skip to content

Instantly share code, notes, and snippets.

@MohamedLamineAllal
Created November 27, 2018 13:23
Show Gist options
  • Save MohamedLamineAllal/238e6f6fc1264f54ea9e99e46fb7cda9 to your computer and use it in GitHub Desktop.
Save MohamedLamineAllal/238e6f6fc1264f54ea9e99e46fb7cda9 to your computer and use it in GitHub Desktop.
Using TIMESTAMPDIFF to get something that is a certain period old (with a where statement)
SELECT *,
TIMESTAMPDIFF(DAY,created_at, CURRENT_TIMESTAMP()) -- just to check it's working
FROM RentCar.companies
where TIMESTAMPDIFF(DAY, created_at, CURRENT_TIMESTAMP()) < 5;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment