Suppose I have a MySQL variable date_stored
of date datatype. I have only the month and year for a particularly date data to be stored in date_stored
. No day information is given. Are there guidelines on what to store in date_stored
if only month and year are known?
Asked
Active
Viewed 103 times
1

guagay_wk
- 26,337
- 54
- 186
- 295
1 Answers
2
MySQL manual says that partial dates can be stored.
Month and day Ranges specifiers begin with zero because MySQL permits incomplete dates storing such as '2015-00-00'
or '2015-10-00'
.
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
So if day part is not given you can still store it as YYYY-MM-00
e.g '2015-10-00'
Also See below related posts.
Store incomplete date in MySQL date field

Community
- 1
- 1

I Bajwa PHD
- 1,708
- 1
- 20
- 42