PostgreSQL 13に現在日時を取得する

環境
Windows10 64 bit
PostgreSQL 13.2
使用例
1.現在日付の取得

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# select * from current_date result;
result
------------
2022-01-08
(1)
postgres=# select * from current_date result; result ------------ 2022-01-08 (1 行)
postgres=# select * from current_date result;
   result
------------
 2022-01-08
(1 行)

2.現在の時刻の取得

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# select * from current_time result;
result
-------------------
19:18:22.83301+09
(1)
postgres=# select * from current_time result; result ------------------- 19:18:22.83301+09 (1 行)
postgres=# select * from current_time result;
      result
-------------------
 19:18:22.83301+09
(1 行)

3.現在日時の取得 now()関数

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# select * from now() result;
result
-------------------------------
2022-01-08 19:19:10.386468+09
(1)
postgres=# select * from now() result; result ------------------------------- 2022-01-08 19:19:10.386468+09 (1 行)
postgres=# select * from now() result;
            result
-------------------------------
 2022-01-08 19:19:10.386468+09
(1 行)

4.現在日時(timestamp)の取得 current_timestampカラム

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# select * from current_timestamp result;
result
-------------------------------
2022-01-08 19:19:41.239124+09
(1)
postgres=# select * from current_timestamp result; result ------------------------------- 2022-01-08 19:19:41.239124+09 (1 行)
postgres=# select * from current_timestamp result;
            result
-------------------------------
 2022-01-08 19:19:41.239124+09
(1 行)

 

PostgreSQL

Posted by arkgame