76.1k views
3 votes
Which statement is true about TIMESTAMP and DATETIME data types?

a) TIMESTAMP is a string type, and DATETIME is numeric.
b) DATETIME has a wider range than TIMESTAMP.
c) TIMESTAMP is stored in UTC, and DATETIME is stored in local time.
d) DATETIME is more suitable for storing time-sensitive data than TIMESTAMP.

User Avivit
by
7.6k points

1 Answer

2 votes

Final answer:

The true statement is that TIMESTAMP is stored in UTC and DATETIME is stored in local time. DATETIME has a wider range, while TIMESTAMP includes timezone information and converts to UTC for storage.

Step-by-step explanation:

The statement that is true about TIMESTAMP and DATETIME data types is (c) TIMESTAMP is stored in UTC, and DATETIME is stored in local time. DATETIME data type stores date and time information without timezone information and does not change if the database server's time zone changes. On the other hand, TIMESTAMP data type stores both date and time, but also includes timezone information by converting stored values from the current timezone to UTC for storage, and back from UTC to the current timezone for retrieval.

Choice (b) is partially correct in that DATETIME has a wider range than TIMESTAMP, as DATETIME can store dates from '1000-01-01 00:00:00' to '9999-12-31 23:59:59', while TIMESTAMP can typically store dates from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC. However, the critical distinction is where each type stores time zone information as stated in choice (c).

User Kunukn
by
8.0k points