I have two options to store the DOB (date of birth) in MySQL. Which is the better method from the following?
Storing DOB using Date Type in MySQL,
Storing DOB values separately in different fields like Day in one field, month in another and year in another?
If the client wants to display the month and date only, is it possible to retrieve it, if we store DOB in date type of MySQL?
Your answers are highly appreciated.
I'd say always store a date as a
DATE type. MySQL has a host of date functions that will calculate time spans, format the date however you'd like to see it, and extract pieces of the date for you.
As an example, if you need the month only, just do
If you need more convincing, take a look around StackOverflow and you'll see hundreds (if not thousands) of questions from folks who are having trouble because their date values are stored as strings.