1
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 3 years have passed since last update.

Postgresで日付から曜日を取得する方法

Posted at

#extract関数を使用する

extract関数してdow (曜日)を数値で取得できます。
関数の詳細はこちら

曜日(0~6、日曜日が 0、timestamp の値のみで使用可)

という仕様なので、arrayの先頭が日曜になるように対応させればOKです。

SELECT
 (array['日','月','火','水','木','金','土'])[EXTRACT(dow FROM timestamp_column)]
FROM table;
1
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
1
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?