0
1

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.

【DB】CONVERT_TZ 関数

Posted at

引数に指定した日時を表す値を別のタイムゾーンに変更した値を取得します。

CONVERT_TZ 関数の使用方法

CONVERT_TZ(dt,from_tz,to_tz)

上記コマンドでは引数に対象となる日時(dt)の現在のタイムゾーン(from_tz)から別のタイムゾーン(to_tz)に変更した場合の日時取得を行なっています。

タイムゾーンは名前付きタイムゾーンUTC(協定世界時)との差などで指定することができます。

# 名前付きタイムゾーン
Asia/Tokyo
America/New_York

# UTC(協定世界時)
+09:00
-05:00 

動かしてみる

select convert_tz('2019-05-14 08:35:14', 'Asia/Tokyo', 'America/New_York');
実際にこのようなコマンドを打っていきます。
image.png
上記のような結果になりました。

select convert_tz('2019-05-14 08:35:14', '+00:00','+09:00');
またこのような別のコマンドを打っていきます。
image.png

上記の結果のように引数である日時のタイムゾーンを変更した日時を取得することができます。

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?