Storing day and month (without year)

前端 未结 3 758
离开以前
离开以前 2020-12-13 04:52

I\'m having trouble with figuring out the best way to store some data in my database. I\'ve got to store DD/MM dates in a database, but I\'m not sure of the best way to stor

3条回答
  •  没有蜡笔的小新
    2020-12-13 05:14

    Are these dates recurring? If not, how will you keep track of when one has "expired"? If the answer is "the app will manually remove the dates once they have expired", then why not simply store the DD/MM date as the next available instance of that date? For example:

    01/02 becomes 2012-02-01, and 04\07 becomes 2011-07-04

    The built-in date/time functions are so useful that I strongly recommend you not use varchars or tinyints.

提交回复
热议问题