-- 事前にDECLAREで変数定義
DECLARE timestamp_date TIMESTAMP;

-- 変数に値を設定
SET timestamp_date = TIMESTAMP('2019-11-01 00:00:00');

SELECT
  SUBSTR(CAST(timestamp_date AS STRING), 1, 4) as y
  SUBSTR(CAST(timestamp_date AS STRING), 1, 7) as ym
  SUBSTR(CAST(timestamp_date AS STRING), 1, 10) as ymd

◆実行結果

おすすめの記事