Date of birth saving to MYSQL DB with timestamp or date column type

dev1234

i am using MYSQL database and would like to know which of this is a good practice.

way 1 - use column type in DB as timestamp. i.e will contain values like 2012-11-13 00:00:00 way 2 - use column as Date. i.e will contain values like 2012-11-13 in the database.

The question here is, to Store DOB. do we really need timestamp as the column type ? also the time section (00:00:00) is not required for a DOB in my opinion.

Should it be timestamp because, then we can store the value as hidden so no body can view it even when somebody see the DB. to view, we must use strtotime() available in php.

Please let me know the correct way to store DOB in database.

Dmitry Pljonkin

I recommend to use DATE.

TIMESTAMP has a range of '1970-01-01 00:00:01' to '2038-01-19 03:14:07' (UTC), so it doesn't fit for DOB in most cases.

It is possible to use DATETIME, but you should ask yourself: do you want users to fill in time of birth? If not - use DATE.

Usually it's not a big deal, but you may also consider required storage:

DATE:      3 bytes 
TIMESTAMP: 4 bytes
DATETIME:  8 bytes

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Convert date format to mysql timestamp

From Dev

Get only the date in timestamp in mysql

From Dev

MySQL Age from Date of Birth (ignore nulls)

From Dev

Calucate age from birth date in mysql

From Dev

MYSQL selecting date on timestamp

From Dev

How to generate number sequence starting with birth date in MySQL

From Dev

Saving Date string to SQL Server date type column in asp.net (vb.net)

From Dev

Laravel4 migration column type of Date of Birth

From Dev

change a column from birth date to age in r

From Dev

Laravel: saving date to MySQL

From Dev

Store date as unix timestamp or TIMESTAMP data type in MySQL?

From Dev

select date of birth dialog

From Dev

Adding date of birth to database

From Dev

How to create mysql table with column timestamp default current_date?

From Dev

MySQL: Changing column type and date time format

From Dev

Convert timestamp to date data type

From Dev

Convert date format to mysql timestamp

From Dev

DHTMLX scheduler date and Time not saving to db

From Dev

Mysql TIMESTAMP TO plain date number

From Dev

Date Of Birth + Birthday SQL

From Dev

Validation for Birth Date, Joining Date and Leaving Date

From Dev

Bootstrap-Date picker date field not saving to mysql db

From Dev

Convert timestamp to date data type

From Dev

Convert historical data in (date )type oracle to unix timestamp considering daylight saving

From Dev

DatePicker validation for Date of Birth

From Dev

Check for Birth Date

From Dev

Date/Timestamp is reset to now() when saving?

From Dev

Add date in timestamp MYSQL

From Dev

get todays birth date from db