0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

BigQueryはじめました: 日付のタイムゾーン調整

0
Last updated at Posted at 2019-10-09

前提

  • 使ってるデータがRDSからのもので、RDS内はもちろん、日本時間ではない。
  • BigQueryへ移行の際、タイムゾーン修正なしなので、当然、日本時間じゃないままのデータを扱っている。
  • Redashでの操作がメインでセッションのタイムゾーン設定なしでやっている。

SQL備忘録

MySQLだと割と、これで調整していました:

DATE_FORMAT(date + interval 9 hour,'%Y%m%d')
date + interval 9 hour

BigQueryでは、この書き方もできる:

DATETIME_ADD(DATETIME(date), INTERVAL 9 HOUR)

が、他にもついでに日付の形式を変えたい時特に便利なやり方がある。

FORMAT_TIMESTAMP('%Y%m%d', offer_date ,'Asia/Tokyo')

→ 時差が何時間とか覚えてなくていいのでズボラな自分にはこっちのほうがFitする。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?