Best way to save only day and month in database -


We will have to save the day and month of the annual reakuring event. (Think of it as the day of the day when the invoice is to be sent to the customer.)

We have to do some calculation with this information. If the customer is paying twice per year then after this we simply do not have to check what this day is today, but also if this day is in 6 months.

We now have several options: a) We save the information in a DATE field but ignore the year. B) We create two int fields in the database date_day and date_month c) We create a varchar field and then do a reggae and partition eg. 31.12 Every time we do some calculations.

We conducted many tests and found that c) is definitely very slow but we still have the option A) and B). First of all, we wanted to go to B) but after some tests we do more for one.

Is there a good technical reason that one option would actually be better than the other?

(We are currently using MySQL, if this is important.)

I want to choose b), because it shows the meaning of the data more accurately. To keep a data structure where some parts are considered "undiscovered", it is problematic. What if people compare just a simple date, assuming that the year is always the same, but someone used a different placeholder year, even though this year does not make any difference?

Always use the data structure that reflects your intentions.

That c) is bad, believe me, beyond proper discussion :-) And I'm not thinking about the reasons for performance ...


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -