2

I'm saving data from a CSV file into a MySQL database. I'm using Laravel and trying to decide what is the best way to store such data. See: http://laravel.com/docs/4.2/schema#adding-columns. Do I use timestamp? Would I lose anything if I just stored it as a string?

StackOverflowNewbie
  • 39,403
  • 111
  • 277
  • 441
  • 3
    how about a `datetime` with '1900-01-01 03:54:32' going into it. Don't go the string route. You will lose all functionality of datemath functions – Drew Sep 24 '15 at 05:00
  • 1
    Indeed mysql datetime does not have the Unix timestamps limitations. Any year from 1000 to 9999 is acceptable. – Déjà vu Sep 24 '15 at 05:01
  • Although `w3school` is not what they recommended here have a look at this link to convert to `MySQL` date format http://www.w3schools.com/sql/func_date_format.asp – usrNotFound Sep 24 '15 at 05:10

1 Answers1

3

Use datetime

The advantage of datetime over string is that it will be stored more efficiently and you will be able to query this data with more tools

Read more in the docs

Jossef Harush Kadouri
  • 32,361
  • 10
  • 130
  • 129