oracle中日期的函式的使用

2022-08-04 09:48:09 字數 1150 閱讀 4944

--oracle中trunc()函式的用法

1.select trunc(sysdate) from dual  --

2019-6-18 今天的日期為209-6-18

2.select trunc(sysdate, '

mm') from dual --

2019-6-1 返回當月第一天.

3.select trunc(sysdate,'

yy') from dual --

2019-1-1 返回當年第一天

4.select trunc(sysdate,'

dd') from dual --

2019-6-18 返回當前年月日

5.select trunc(sysdate,'

yyyy

') from dual --

2019-1-1 返回當年第一天

6.select trunc(sysdate,'

d') from dual --

2019-6-17 (星期天)返回當前星期的第一天

7.select trunc(sysdate, '

hh') from dual --

2019-6-18 16:53:00 當前時間為16:53

8.select trunc(sysdate, '

mi') from dual --

2019-6-18 16:53:00 trunc()函式沒有秒的精確

9.select trunc(sysdate-

1) from

dual; 返回當前時間第一天

10.select add_months(trunc(sysdate),-

1) from

dual; 返回前乙個月日期

11.select trunc(add_months(trunc(sysdate),-

1),'

mm')from

dual;

12.select to_char(add_months(trunc(sysdate),1),'

yyyymm

')from dual;

-------------------希望能夠對大家有幫助!!!

Oracle中日期的計算

日期格式引數含義說明 d 一周中的星期幾 day 天的名字,使用空格填充到9個字元 dd 月中的第幾天 ddd 年中的第幾天 dy 天的簡寫名 iw iso標準的年中的第幾周 iyyy iso標準的四位年份 yyyy 四位年份 yyy,yy,y 年份的最後三位,兩位,一位 hh 小時,按12小時計 ...

Oracle中日期處理

獲取oracle詳細建表語句 select dbms metadata.get ddl table t test ddl from dual 查詢資料儲存結構,字元長度 select dump 漢字 lengthb 漢字 from dual trunc把乙個日期擷取,只取到年。資料庫只是把最後5個位...

oracle中日期轉換

oracle中,日期轉換函式有很多,常用命令如下 select to char sysdate,yyyy mm dd hh24 mi ss from dual 語法 to char x format 說明 將x按format格式轉換成字串。x可以是日期或者數字或時間戳,format是乙個規定了x採用...