I want to store some dates into MySQL but those dates are without years field.
What’s the best way to do it?
It’s best if I can utilize those two MySQL functions in my queries: DATE_SUB(), DATE_ADD(); because I want to query date spans that covers the current MM-DD.
ADD:
- I have 100% control over the input and output code;
- I have two MM-DD dates in a row to represent a date span
- I’m not intending to save space by doing this, but I’m doing this just because in my requirements I need to store important MM-DD dates and return the date span that covers current MM-DD no matter what year it is now, it’s like a “holiday reminder” or something like that
If you have 100% control over all the code that directly reads or writes this data, you could just use a normal
DATEfield, and always set the year to the same constant value.Then, you can use
DATE_ADD()etc. in your queries normally, you just have to omit the year whenever you return some of those dates.