The most efficient method for storing dates in a database?

So, I'm looking to store a date in my SQL database, and I'm not sure what the most efficient way would be. I thought of two different methods.

Firstly, people will be able to set a certain price for each day.

For instance:

March 8, 2011: $ 1

March 9, 2011: $ 2

March 10, 2011: $ 5

For my database, I thought of either storing the UNIX timestamp, or storing the month, day, and year in separate fields.

First method:

UNIX Timestamp

pros

  • Only one field

against

  • Need to convert date to timestamp
  • You must search between start and end dates
  • Search Error Prevention

Month / day / year

pros

  • Easier to search

against

  • Additional fields
  • Takes up more space
  • Will store a lot of data, which can slow down the database.

, ? ( , .)

+3
3

timestamp/datetime/date ( ).
. () , , (... ... ), , .
, .

+9

DATE, .

+4

DATETIME DATE - ...

+2

All Articles