Skip to content

Instantly share code, notes, and snippets.

@revox
Created July 22, 2015 08:25
Show Gist options
  • Save revox/2ad8354c96706fa7346f to your computer and use it in GitHub Desktop.
Save revox/2ad8354c96706fa7346f to your computer and use it in GitHub Desktop.
Convert tweet dates into MySQL dates
/* Tweet dates look like this Tue Apr 21 18:07:47 +0000 2015 */
/* test */
SELECT STR_TO_DATE('Tue Apr 21 18:07:47 +0000 2015', '%a %b %d %H:%i:%s +0000 %Y');
/* import stringdate into fake date column which has type VARCHAR, then add a DATETIME column and the do this */
UPDATE tweets SET tweetdate = STR_TO_DATE(fake, '%a %b %d %H:%i:%s +0000 %Y');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment