Skip to content

Instantly share code, notes, and snippets.

@MohamedLamineAllal
Created November 27, 2018 13:23
Show Gist options
  • Save MohamedLamineAllal/8eeb6115bd52ba97f9bb4e8430a94d7b to your computer and use it in GitHub Desktop.
Save MohamedLamineAllal/8eeb6115bd52ba97f9bb4e8430a94d7b 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