Skip to content

Instantly share code, notes, and snippets.

@slav123
Created March 28, 2017 07:52
Show Gist options
  • Save slav123/ad2424925fcbd7e3218cc2e1f91e21da to your computer and use it in GitHub Desktop.
Save slav123/ad2424925fcbd7e3218cc2e1f91e21da to your computer and use it in GitHub Desktop.
MySQL select records older then... in timestamp
SELECT id, DATE_FORMAT(FROM_UNIXTIME(`time`), '%e %b %Y') AS 'date_formatted' FROM api_logs WHERE `time` < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 3 MONTH)) ORDER BY id DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment