[英]How to specify timestamp format in Oracle SQL
它以非常糟糕的方式顯示它,但我需要成為小時:分鍾。
SELECT DepName, ARRSTATIONNAME, VEHICLENUMBER, ARRVTIME - DEPTIME FROM VEHICLENUMBER...
ARRVTIME - DEPTIME
是我需要進行格式化的地方,因為我得到了
+000000000 02:28:00.000000
看起來你正在處理時間戳。 如果是這樣,看看這個例子:
樣品表:
SQL> create table test (arrvtime timestamp, deptime timestamp);
Table created.
SQL> insert into test values (systimestamp, systimestamp - 0.2);
1 row created.
SQL> select * From test;
ARRVTIME DEPTIME
------------------------------- -------------------------------
08.05.20 21:04:50,508000 08.05.20 16:16:50,000000
您可能需要的查詢:
SQL> select arrvtime - deptime diff,
2 extract(hour from arrvtime - deptime) hours,
3 extract(minute from arrvtime - deptime) minutes,
4 --
5 -- what you want
6 extract(hour from arrvtime - deptime) ||':'||
7 extract(minute from arrvtime - deptime) result
8 from test;
DIFF HOURS MINUTES RESULT
------------------------------- ---------- ---------- ------
+000000000 04:48:00.508000 4 48 4:48
SQL>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.