mysql - What is the best data type for DATE and TIME -
i have application saves date , time of transaction. initial database design create separate fields date
date , time
varchar. second option have single field datetime
.
what difference of these two??
i recommend use timestamp track every change made database. shou;d use datetime datatype if want store specific value of date , time in column. if want track changes made in values recommend use timestamp. mysql docs:
the datetime type used when need values contain both date , time information. mysql retrieves , displays datetime values in 'yyyy-mm-dd hh:mm:ss' format. supported range '1000-01-01 00:00:00' '9999-12-31 23:59:59'.
...
the timestamp data type has range of '1970-01-01 00:00:01' utc '2038-01-09 03:14:07' utc. has varying properties, depending on mysql version , sql mode server running in.