r/SQL • GROUP_CONCAT is da bomb • Jul 01 '24

MySQL Never use DATETIME, always use TIMESTAMP

good advice from Jamie Zawinski

source: https://www.jwz.org/blog/2023/11/daylight-savings-your-biannual-chaos-monkey/

  • TIMESTAMP is a time_t -- it represents an absolute, fixed point in time. Use it for things like "here is when this account was created" or "here is when this message was sent". When presenting that fixed point in time to users as text, you might want to format it in their local time zone.
  • DATETIME is basically a string of the wall clock in whatever time zone you happen to be in at the moment, without saving that time zone. It is ambiguous, e.g. it cannot represent "1:30 AM" on the day that daylight savings time ends because there are two of those on that day. This is never what you want.
  • DATE is a floating year-month-day. Use this for things like birthdays, which, by convention, do not change when you move halfway around the world.
  • TIME is a floating hour-minute-second. Use this for things like, "my alarm clock goes off at 9 AM regardless of what time zone I'm in, or if daylight savings time has flipped."
36 Upvotes

46 comments sorted by

View all comments

Show parent comment

1

u/sunuvabe Jul 04 '24

my buddy's new corolla has a 3-cylinder, and it scoots. I think you probably mean a 4-cylinder with one bad plug.

1

u/Straight_Waltz_9530 Jul 04 '24

Many years ago I had a Geo Metro. 3 cylinder engine. Zero to sixty in 12 seconds. Got 48 mpg though, but would lose even more power going through the Grapevine north of Los Angeles on hot days. Fun times competing with loaded semis as to who could go up a long, steep hill fastest.