Data Type Required In A Mysql For A Date Containing Day-month-year
Hi guys I'm using wamp server and I have a database with a date of birth field. I would simply like to know what data type would be suitable for the way date of birth is specified
Solution 1:
When saving date in the database, use the correct datatype DATE
or DATETIME
. Don't use VARCHAR
Pros:
- easy to manipulate
- requires no casting when manipulating data
- index will be used (if a key was defined)
Cons
- can't think of something..
If the reason why you want to save date in this format January 01 1996
is because it is more readable than 1996-01-01
, then don't. This can be achieve using DATE_FORMAT()
during the projection of the data.
Post a Comment for "Data Type Required In A Mysql For A Date Containing Day-month-year"