Skip to content

Instantly share code, notes, and snippets.

@Artem-Schander
Created March 24, 2017 08:49
Show Gist options
  • Save Artem-Schander/c007bf715db2a2f350244b4897d26e96 to your computer and use it in GitHub Desktop.
Save Artem-Schander/c007bf715db2a2f350244b4897d26e96 to your computer and use it in GitHub Desktop.
MySQL Query to get a duration in days by two unix timestamps
SELECT name, TIMESTAMPDIFF(DAY, DATE(FROM_UNIXTIME(date_start)), DATE(FROM_UNIXTIME(date_end))) + 1 AS duration
FROM some_table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment