Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigQuery - Datetime vs Timestamp

I looked on the documentation for google big query data types, checking the differences between TimeStamp to Datetime data types.

As I understand the main difference is:

Unlike Timestamps, a DATETIME object does not refer to an absolute instance in time. Instead, it is the civil time, or the time that a user would see on a watch or calendar.

So when should I use Timestamp/Datetime?

Thanks

like image 404
NirKa Avatar asked Dec 08 '17 11:12

NirKa


People also ask

What is the difference between datetime and TIMESTAMP BigQuery?

Datetime type: comprises both calendar date and time. It does not store time zone information: YYYY-MM-DD HH:MM:SS (e.g. ). Timestamp type: comprises date, time, and time zone information.

What is the difference between datetime and TIMESTAMP?

The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' . The TIMESTAMP data type is used for values that contain both date and time parts.

What is TIMESTAMP in BigQuery?

Description. CURRENT_TIMESTAMP() produces a TIMESTAMP value that is continuous, non-ambiguous, has exactly 60 seconds per minute and does not repeat values over the leap second. Parentheses are optional. This function handles leap seconds by smearing them across a window of 20 hours around the inserted leap second.


1 Answers

In most cases you will want to use the timestamp data type. It refers to an absolute point in time. BigQuery interprets any timezone information and represents the time internally as a UTC timestamp.

Very rarely would you use a datetime data type, which is a date and a time but no time zone. The example I like to give is that you'd use a datetime to represent pi day, 2017, since it occurs at 2017-03-14 15:09:26.535898 in each time zone separately.

like image 83
Tim Swast Avatar answered Sep 18 '22 14:09

Tim Swast