I have a MySQL table where there is a ‘date_added’ (date) field, ‘time_added’ (time) field and ‘timestamp’ (int) field.
I found out afterwards that I can convert timestamp to a date or a time anyway, so so does that mean I could get rid of the other date/time fields and keep the timestamp only?
Thanks in advance
In the layout you describe I see no reason to have more than one field. You can use a
DATETIMEcolumn or, if you are fond of DB magic, aTIMESTAMPcolumn (don’t confuse it with unix timestamps). The first TIMESTAMP in a table can be configured to autoupdate itself.It’s also worth noting that some platforms allow very narrow ranges of dates when using Unix timestamps (it can be problematic to store a date before 1970 or after 2038) while MySQL’s DATETIME type ranges from year 1000 to 9999.
http://dev.mysql.com/doc/refman/5.1/en/datetime.html