oracle trunc 用法 trunc(sysdate)

 时间:2026-02-12 04:38:39

1、select trunc(sysdate) from dual  结果是 截止到当日

不设置,默认是截止到”日“

oracle trunc 用法 trunc(sysdate)

2、select trunc(sysdate,'year') from dual; 

--获取到本年 第一天

oracle trunc 用法 trunc(sysdate)

3、select trunc(sysdate,'month') from dual; 

--获取到 本月 第一天 

oracle trunc 用法 trunc(sysdate)

4、select trunc(sysdate,'q') from dual; 

--获取到本季度 第一天

oracle trunc 用法 trunc(sysdate)

5、select to_char(trunc(sysdate),'yyyy-mm-dd hh24:mi:ss') from dual; 

--默认获取到日(当日的零点零分零秒)

oracle trunc 用法 trunc(sysdate)

6、select trunc(sysdate,'iw') from dual; 

--本周一

oracle trunc 用法 trunc(sysdate)

7、select trunc(sysdate,'ww') from dual;  

-- 获取离当前时间最近的周四,若当天为周四则返回当天,否则返回上周四

oracle trunc 用法 trunc(sysdate)

8、select trunc(sysdate,'day') from dual; 

--获取到周(本周第一天,即上周日)

oracle trunc 用法 trunc(sysdate)

9、select trunc(sysdate,'hh24') from dual;  

--截取到小时(当前小时,零分零秒)

oracle trunc 用法 trunc(sysdate)

10、select trunc(sysdate,'mi') from dual; 

--截取到分(当前分,零秒)

oracle trunc 用法 trunc(sysdate)

  • update set多个字段update更新多个字段另类方法
  • notepad++怎么设置自动换行?
  • Notepad++标签显示橙色条如何去掉呢?
  • plsql如何执行.sql文件
  • SQL错误:Sql command not properly ended
  • 热门搜索
    涨停是什么意思 口红是用什么做的 产值是什么意思 小腹胀痛是什么原因 汽油什么时候涨价 科目二考什么 荨麻疹用什么药 吃维生素c有什么好处 梦见大鱼是什么意思 fix是什么意思