views:

52

answers:

1

I've got a database of historical records from WW2 and currently each recorded event's date is stored in one integer field as YYMMDDHHMM. This makes simple tasks like ORDER BY, or searching for all events within a certain time period extremely easy. However, if somebody wants all events that occurred on December 1st in any year of the war that's a bit of a pain, and when displaying records to the visitor that string must be broken up into 5 variables for formatting purposes making for rather ugly PHP code. (well, at least when I write it, ha)

Does anyone have an idea of the performance consequences if we broke that string into 5 discrete columns? Or if we kept the original column for those searches it is useful for and appended 5 more columns (Year, Month, Day, Hour, Minute) for ease of data display?

This is an obvious duplication of data, and in the same table no less, which is kind of a normalization no-no is it not? But it would seem to make the PHP side of things much easier...

Thank you kindly,

  • A
+1  A: 

Why not use MySQL's datetime field and the vast array of functions that make date-related queries a snap?

Mike B
i agree with Mike, datetime it's a cleaner solution than using an integer field that you have to parse each time
wezzy
That would seem to be the sensible thing to do, wouldn't it? Time to go write a PHP script to convert all the existing records! Thank you for the slap of reality.
Andrew Heath