Best way to store belongings?

MySQL. Storing dates (any, every year).  Only care about  month-day, such as 01-12 (12th jan). What is the best way to store "yearless" dates like this?

  • I know i can store, for instance 2014-01-12, and just disregard the year. Or even store and invalid date, which is ok to store in a DATE type, as 0000-01-12. My question should really be what do you do, and what do you think is the best way to do this?  I've done this previously and always thought it was a bit hacky either way.

  • Answer:

    I assume you are storing yearly recurring events (birthdays ?) as you are disregarding the year. If you don't need to perform many datetime operations, you could have columns for day and month. Those can be enumerations since you have just 12 months and at most 31 days. Alternatively you could have single column with enumeration for all 366 days. In case you need to store as date, I recommend keeping the year and disregarding it. Retaining user input might help in the future.

Nayan Shah at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.