views:

47

answers:

3

Do you lose any data when converting a timestamp to datetime in mysql? Also what are the major differences between the two?

A: 
  1. No you don't. You lose data if you convert datetime or timestamp to date (since date do not store time data).
  2. for detailed info about the differences between the two, you can read this question
bangbambang
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
A: 

You can create an extra column and a query to copy your data into that column before you venture the conversion.

cfEngineers