oracle trunc函数用法
转自:https://www.e-learn.cn/content/qita/699481
/**************日期********************/
select trunc(sysdate) from dual ;--2011-3-18 今天的日期为2011-3-18
select trunc(sysdate, 'mm') from dual ; --2011-3-1 返回当月第一天.
select trunc(sysdate,'yy') from dual; --2011-1-1 返回当年第一天
select trunc(sysdate,'dd') from dual; --2011-3-18 返回当前年月日
select trunc(sysdate,'yyyy') from dual; --2011-1-1 返回当年第一天
select add_months(to_date('2018-01-01','yyyy-mm-dd'),12)-1 from dual; -- 2018-12-31 返回当年第一天
select trunc(sysdate,'d') from dual ; --2011-3-13 (星期天)返回当前星期的第一天
select trunc(sysdate, 'hh') from dual ; --2011-3-18 14:00:00 当前时间为14:41
select trunc(sysdate, 'mi') from dual ; --2011-3-18 14:41:00 TRUNC()函数没有秒的精确
SELECT to_date('20180818','yyyymmdd')-to_date('20180727','yyyymmdd') FROM dual;
/***************数字********************/
/*
TRUNC(number,num_digits)
Number 需要截尾取整的数字。
Num_digits 用于指定取整精度的数字。Num_digits 的默认值为 0。
TRUNC()函数截取时不进行四舍五入
*/
select trunc(123.458) from dual; --123
select trunc(123.458,0) from dual ;--123
select trunc(123.458,1) from dual ;--123.4
select trunc(123.458,-1) from dual; --120
select trunc(123.458,-4) from dual; --0
select trunc(123.458,4) from dual ;--123.458
select trunc(123) from dual ;--123
select trunc(123,1) from dual ;--123
select trunc(123,-1) from dual ;--120
oracle trunc函数用法的更多相关文章
- Oracle trunc()函数的用法
Oracle trunc()函数的用法 /**************日期********************/1.select trunc(sysdate) from dual --2013-0 ...
- oracle获取本月第一天和最后一天及Oracle trunc()函数的用法
select to_char(trunc(add_months(last_day(sysdate), -1) + 1), 'yyyy-mm-dd') "本月第一天", to_cha ...
- Oracle trunc()函数的用法--来着心静禅定ing
1.TRUNC(for dates) TRUNC函数为指定元素而截去的日期值. 其具体的语法格式如下: TRUNC(date[,fmt]) 其中: date 一个日期值 fmt 日期格式,该日期将由指 ...
- Oracle trunc()函数的用法及四舍五入 round函数
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2011 ...
- [转]Oracle trunc()函数的用法
原文地址:http://www.cnblogs.com/gengaixue/archive/2012/11/21/2781037.html 1.TRUNC(for dates) TRUNC函数为指定元 ...
- Oracle trunc()函数,decode()函数,substr函数,GREATEST函数,java中substring函数的用法
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...
- Oracle trunc函数
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2011 ...
- Oracle trunc()函数
Oracle trunc()函数的用法 --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysd ...
- Oracle trunc() 函数处理数字、日期的整理
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...
随机推荐
- java中 try catch的妙用
程序开发中,格式转换的时候,经常由于字符串可能是其他的不可预知的符号导致,字符串转数值失败, 这个时候可以妙用try catch来解决,如下图所示.其实,很多其他不可预知的异常情况,也可以用它来处理. ...
- osg 渲染ifc数据-测试
直接使用osg渲染ifc数据,提高渲染速度. #include "teslamanage.h" #include <QtWidgets/QApplication> #i ...
- 一个80后妈妈的邪淫忏悔(转自学佛网:http://www.xuefo.net/nr/article55/551761.html)
我是一个80后独生女,2012年因为孩子小产后,痛苦难当,悲伤中想起可为孩子超度,因此开始了与佛法的缘分.断断续续几年的学习,才真的知道了邪淫的可怕 我从小面容姣好,气质超群,一直被父母,老师宠爱.想 ...
- Spring MVC 数据转换和格式化
HttpMessageConverter和JSON消息转换器 HttpMessageConverter是定义从HTTP接受请求信息和应答给用户的 HttpMessageConverter是一个比较广的 ...
- LabWindows/CVI入门之第四章:库文件(转)
按语: 在参考CVI参考书使用CVI生成动态库后,在另一工程中调用DLL ,编译通不过,后参考此文,豁然开朗. http://blog.sina.com.cn/s/blog_6373e9e60101b ...
- iphone那些事儿
1.微信文件如何发送到钉钉? 打开微信的某文件,点击右上角三个点,选择其他应用打开,选择钉钉.即可复制文件到钉钉. 2.无限网地址 设置-通用-关于本机-无线局域网地址 锂离子电池,受气温影响,气温低 ...
- 推荐两本CCF教材
希望学习电脑程序设计的同学,可以购买如下两本教材,先学习入门篇,再学习基础篇.淘宝.当当.京东均有售.建议选择比较靠谱的网店,避免买到盗版书.
- [转帖]微软 SQ1 参数一览:8 核 Kryo 495,Adreno 685 GPU
微软 SQ1 参数一览:8 核 Kryo 495,Adreno 685 GPU http://www.myzaker.com/article/5d989ef68e9f0977765e5506/ 微软发 ...
- SSRS Reporting Service安装与部署
安装与部署SSRS步骤 什么是SSRS SQL Server Reporting Serivces(SSRS) 是一种强大的报表设计开发工具或者说是服务,它提供了一系列本地工具和服务,用于创建.部署和 ...
- SpringBoot中使用@Scheduled创建定时任务
SpringBoot中使用@Scheduled创建定时任务 定时任务一般会在很多项目中都会用到,我们往往会间隔性的的去完成某些特定任务来减少服务器和数据库的压力.比较常见的就是金融服务系统推送回调,一 ...