Storing day and month (without year)

前端 未结 3 759
离开以前
离开以前 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:18

    If you really really want to drop the year, then just make TWO columns, one for day and another for month. Then store them separately.

    CREATE TABLE `table-name` (
      `Day` tinyint NOT NULL,
      `Month` tinyint NOT NULL
    );
    

    But, it's much better to just use the Date type and then ignore the year in your code.

提交回复
热议问题