Skip to content

Instantly share code, notes, and snippets.

@alordiel
Last active May 30, 2019 09:24
Show Gist options
  • Save alordiel/acec8e72c08bb3016270a53ed029b684 to your computer and use it in GitHub Desktop.
Save alordiel/acec8e72c08bb3016270a53ed029b684 to your computer and use it in GitHub Desktop.
MySQL query to split DATE into Year, Month, Day, Hour and record in relative columns
UPDATE `events` as EE
LEFT JOIN events as EE1
ON EE.ID = EE1.ID
SET EE.Year = YEAR(EE1.created),
EE.Month = MONTH(EE1.created),
EE.Day = DAY(EE1.created),
EE.Hour = TIME(EE1.created),
EE.DayOfWeek = DAYOFWEEK(EE1.created)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment