oracle日期函數、字符串函數、格式化方式


select last_day(sysdate) from dual;--某個時間對應月份的最后一天

select next_day(sysdate,'星期二') from dual;--某個時間對應星期的下一周期

select add_months(sysdate,2) from dual;--某個時間對應月份的下幾個月份

select ename,trunc(months_between(sysdate,hiredate)) from emp;--員工入職至現在共計多少個月

select to_char(sysdate,'yyyy-mm-dd') time from dual;--某個時間以XX格式顯示

select to_char(sysdate,'yyyy') year ,to_char(sysdate,'mm') month,to_char(sysdate,'dd')from dual;--查詢某個時間所對應年、月、日、時。分、秒

select to_char(sysdate,'yyyy-mm-dd hh:mi:ss') time from dual;--某個時間以XX格式顯示(12小時:時分秒)

select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') time from dual;--某個時間以XX格式顯示(24小時:時分秒)

select to_char(890783453485,'999,999,999,999,999,999') from dual;--以某格式顯示傳入參數

select to_char(890783453485,'L999,999,999,999,999,999') from dual;--(L代表當前語言環境下的貨幣符號)

select to_date('1989-06-24','yyyy-mm-dd') from dual;--格式化時間

alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';--更改當前會話的日期顯示方式

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM