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 1 year has passed since last update.

【PostgreSQL】システム日付の取得

Posted at

SQLで現在のシステム日付を取得する文法って、いつも覚えられなくてググるので、この機会に備忘のためにメモ。
様々なデータ型で取得できるので、その方法も合わせて。

日付のみ形式

「CURRENT_DATE」 を使う

query.sql
SELECT CURRENT_DATE;
result.sql
2022-07-16

時間のみ形式

「CURRENT_TIME」 を使う

query.sql
SELECT CURRENT_TIME;
result.sql
08:25:36.000000-00

日付+時間のみ形式

「CURRENT_TIMESTAMP」 を使う

query.sql
SELECT CURRENT_TIMESTAMP;
result.sql
2022-07-16 08:25:36.000000-00

日付/時刻関数と演算子 - 現在の日付/時刻

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?