Do you lose any data when converting a timestamp to datetime in mysql? Also what are the major differences between the two?
A:
- No you don't. You lose data if you convert datetime or timestamp to date (since date do not store time data).
- for detailed info about the differences between the two, you can read this question
bangbambang
2010-10-02 00:44:01
A:
From the docs (TIMESTAMP Propeties):
TIMESTAMP values are converted from the current time zone to UTC for storage, and converted back from UTC to the current time zone for retrieval. (This occurs only for the TIMESTAMP data type, not for other types such as DATETIME.) By default, the current time zone for each connection is the server's time.
[...]
If you store a TIMESTAMP value, and then change the time zone and retrieve the value, the retrieved value is different from the value you stored. This occurs because the same time zone was not used for conversion in both directions.
ars
2010-10-02 00:45:00
A:
You can create an extra column and a query to copy your data into that column before you venture the conversion.
cfEngineers
2010-10-02 04:15:21