2

What would be the best way to store date and time in sql databases? Should i use date() or is there some other better way to do it? and if i should be able to sort by the dates, what kind of sql row should it be set to? a timestamp or datetime?

Matthew
  • 105
  • 4
  • Check out this somewhat related post, regarding DATETIME vs TIMESTAMP http://stackoverflow.com/questions/409286/datetime-vs-timestamp – Bryan Oct 13 '12 at 22:49

1 Answers1

2

Both, the DATETIME and TIMESTAMP can be sorted in their default formats. Using one of these two is the best way to follow instead of storing them as VARCHAR or other data-types.

I personally prefer using DATETIME over TIMESTAMP because of the limitation applied to it.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183