oracle trunc()函数的用法 1.TRUNC(for dates)TRUNC函数为指定元素而截去的日期值。其具体的语法格式如下:TRUNC(date[,fmt])            
                
         
            
            
            
            trunc对日期按格式截尾  对数字按位数-1)    -120            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-05-17 11:38:45
                            
                                198阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            In Oracle/PLSQL, the trunc function returns a date truncated to a specific unit of measure.
The syntax for the trunc function is:
trunc ( date, [ format ] )
date is the date to truncate.
forma            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2011-09-01 16:39:13
                            
                                828阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss'), to_char(trunc(sysdate), 'yyyy-mm-dd hh24:mi:ss') from dual t;--sysdate和trunc(sysdate)是不一样的 sysdate在当            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2016-03-02 20:16:00
                            
                                210阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            前言 trunc  是 truncate 的简写。中文翻译是 “截断”或 “截短”。表面看上去,应该是对字串或是数字进行截取。 实际上这个函数有两种用法, 而且这两种用法看上去很不一样。1. 对 number 类型使用。其工作机制与ROUND函数极为类似,只是该函数不对指定小数前或后的部分做相应舍入选择处理,而统统截去。2. 对日期类型使用。 对 number 类型使用语法格式            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2024-01-02 10:39:37
                            
                                570阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            /**************日期********************/ select trunc(sysdate) from dual  ;--2011-3-18  今天的日期为2011-3-18select trunc(sysdate, 'mm')   from   dual ; --2011-3-1    返回当月第一天.select trunc(sysdate,'yy') from            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2019-07-22 17:10:00
                            
                                176阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            --截取后得到的仍为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(sysda ...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2021-10-16 20:47:00
                            
                                412阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            --截取后得到的仍为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(sysda            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2021-07-28 11:17:15
                            
                                895阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            一、处理日期select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;  --显示当前时间select trunc(sysdate,'year') from dual; --截取到年(本年的第一天)select trunc(sysdate,'q') from dual; --截取到季度(本季度的第一天)select tru...            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-04-24 11:29:11
                            
                                989阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            http://blog.sina.com.cn/s/blog_608e209301016tdf.htmlselect trunc(sysdate-1) from dual;1.TRUNC(fordates)  TRUNC函数为指定元素而截去的日期值。  其具体的语法格式如下:  TRUNC(date[,fmt])  其中:  date一个日期值  fmt日期格式,该日期将由指定的元素格式所截去。忽            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                            精选
                                                        
                            2013-09-13 20:51:09
                            
                                432阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual  --2011-3-18  今天的日期为2011-3-182.select trunc(sysdate, 'mm')   from   dual  --2011-3-1    返回当月第一天.            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-02-23 14:01:46
                            
                                777阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            --Oracle trunc()函数的用法/***年第一天4.select trunc(sysdate,'dd') from dual -            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2014-03-04 16:07:00
                            
                                109阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
             --Oracle trunc()函数的用法
/**************日期********************/
1.select trunc(sysdate) from dual  --2011-3-18  今天的日期为2011-3-18
2.select trunc(sysdate, 'mm')   from             
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                            精选
                                                        
                            2012-12-27 10:29:21
                            
                                499阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            trunc用法            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2018-01-16 10:13:12
                            
                                758阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            /**************日期********************/1.select trunc(sysdate) from dual --2013-01-06 今天的日期为2013-01-062.select trunc(sysdate, 'mm') from dual --2013-01            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2017-10-10 10:21:00
                            
                                87阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            Oracle trunc()函数的用法 --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013-01-06 今天的日期为2013-01-062.select            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2017-11-27 18:10:00
                            
                                108阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
               Oracle中的函数——Trunc()
    
        trunc(exp1)trunc(exp1)和Round(exp1,exp2)类似,只不过trunc()不指定截取的小数位数进行处理,只取到整数位,不做舍去处理select trunc(123.1234) from dual ---123select trunc(123.9234) from dual ---123-----            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2021-04-28 21:20:35
                            
                                240阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            1. 对日期的操作2. 对数字的操作1、对日期的操作/**************日期********************/
SELECT TRUNC(SYSDATE) FROM DUAL; --2019/11/29 今天的日期为2019/11/29
SELECT TRUNC(SYSDATE, 'MM') FROM DUAL; --2019/11/01 返回当月第一天.
SELECT TRUN            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2021-04-28 22:29:35
                            
                                222阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            --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 t            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2014-05-09 10:16:00
                            
                                67阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            1、日期比较时精确到日,可以使用 TRUNC(sysdate,'dd')函数。函数支持格式有:yyyy MM  dd  hh Mi2、trunc(d1[,c1])  返回日期d1所            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-08-18 13:52:34
                            
                                379阅读