select trunc(20171106/100,0) from tabledate --------------结果为201711select trunc(20171106/10000,0)*100 from tabledate -----结果为201700两个值相减就是月份了,两表对比查询时,20171106 可以用字段替换,如:select * from tablename a, tabledate b where a.month = trunc(b.beg_date / 100, 0) - runc(b.beg_date / 10000, 0) * 100原文:https://www.cnblogs.com/docstrange/p/13680889.html
/**************日期********************/1.select trunc(sysdate) from dual --2013-01-06 今天的日期为2013-01-062.select trunc(sysdate, ‘mm‘) from dual --2013-01-01 返回当月第一天.3.select trunc(sysdate,‘yy‘) from dual --2013-01-01 返回当年第一天4.select trunc(sysdate,‘dd‘) from dual --2013-01-06 返回当前年月日5.select trunc(sysdate,‘yyyy‘) from dual --2013-01-01 返回当...
--Oracle trunc()函数的用法/**************日期********************/select trunc(sysdate) from dual --2011-3-18 今天的日期为2011-3-18select 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 ...
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013-01-06 今天的日期为2013-01-062.select trunc(sysdate, ‘mm‘) from dual --2013-01-01 返回当月第一天.3.select trunc(sysdate,‘yy‘) from dual --2013-01-01 返回当年第一天4.select trunc(sysdate,‘dd‘) from dual --2013-01-06 返回当前年月日5.select trunc(sysdate,‘yyyy‘) from dual --2013-01-01 返回...
/**************日期 TRUNC()函数没有秒的精确 ********************/select sysdate from dual --当时日期select trunc(sysdate) from dualselect trunc(sysdate ,‘DD‘) from dual --今天日期select trunc(sysdate,‘d‘)+7 from dual --本周星期日select trunc(sysdate,‘dy‘)+7 from dual --本周星期日select trunc(sysdate,‘day‘)+7 from dual --本周星期日select trunc(sysdate,‘q‘) from dual--本季开始日期select ...
/**************日期********************/select trunc(sysdate) from dual --2011-3-18 今天的日期为2011-3-18select 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 tru...
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013-01-06 今天的日期为2013-01-062.select trunc(sysdate, ‘mm‘) from dual --2013-01-01 返回当月第一天.3.select trunc(sysdate,‘yy‘) from dual --2013-01-01 返回当年第一天4.select trunc(sysdate,‘dd‘) from dual --2013-01-06 返回当前年月日5.select trunc(sysdate,‘yyyy‘) from ...
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2011-3-18 今天的日期为2011-3-182.select trunc(sysdate, ‘mm‘) from dual --2011-3-1 返回当月第一天.3.select trunc(sysdate,‘yy‘) from dual --2011-1-1 返回当年第一天4.select trunc(sysdate,‘dd‘) from dual --2011-3-18 返回当前年月日5.select trunc(sysdate,‘yyyy‘) from dual -...
Oracle trunc()函数的用法标签:本文系统来源:http://www.cnblogs.com/nmliu/p/5929517.html
本文系统来源:http://www.cnblogs.com/dirgo/p/6404260.html
trunc函数
date为必要参数
语法格式TRUNC(date,[fmt])select sysdate from dual; --当前时间 2016/9/7 10:32:04select trunc(sysdate) from dual;--取当天 2016/9/7select trunc(sysdate,‘yyyy‘) from dual; --取当年第一天 2016/1/1select trunc(sysdate,‘mm‘) from dual; --取当月第一天 2016/9/1select trunc(sysdate,‘dd‘) from dual; --取当天 2016/9/7select trunc(sysdate,‘d‘) from dual; --返回当前星期的第...
1、取当年的第一天和当年的最后一天select trunc(sysdate,‘YYYY‘),add_months(trunc(sysdate,‘YYYY‘),12)-1 from dual t
select to_char(trunc(add_months(last_day(sysdate), -1) + 1), ‘yyyy-mm-dd‘) "本月第一天", to_char(last_day(sysdate), ‘yyyy-mm-dd‘) "本月最后一天" --Oracle trunc()函数的用法 /**************日期********************/ 1.select trunc(sysdate) from dual --2011-3-18 今天的日期为2011-3...
--截取后得到的仍为date数据类型
select trunc(sysdate) from dual;--2017-03-13 00:00:00select trunc(sysdate+1) from dual;--2017-03-14 00:00:00 加一天
select trunc(sysdate,‘yyyy‘) from dual;--2017-01-01 00:00:00select trunc(sysdate,‘MM‘) from dual;--2017-03-01 00:00:00select trunc(sysdate,‘DD‘) from dual;--2017-03-13 00:00:00
select trunc(sysdate,‘HH‘) from dual;--2017-03-13 11:00:00select tru...
to_char(sysdate, ‘yyyy-mm-dd hh24:mi:ss‘) from dual; --显示当前时间
2017 - 04 - 24 18 :42 :17select trunc(sysdate, ‘year‘) from dual; --截取到年(本年的第一天)
2017 / 1 / 1select trunc(sysdate, ‘q‘) from dual; --截取到季度(本季度的第一天)
2017 / 4 / 1select trunc(sysdate, ‘month‘) from dual; --截取到月(本月的第一天)
或select trunc(sysdate, ‘mm‘) from dual; --截取到月(本月的第一天)...
select to_char(trunc(add_months(last_day(sysdate), -1) + 1), ‘yyyy-mm-dd’) “本月第一天”,to_char(last_day(sysdate), ‘yyyy-mm-dd’) “本月最后一天”–Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual –2011-3-18 今天的日期为2011-3-182.select trunc(sysdate, ‘mm’) from dual –2011-3-1 返回当月第一天.3.select trunc(sysdate,’yy’) from du...