date 为必要参数,是输入的一个日期值
fmt 参数可忽略,是日期格式,用以指定的元素格式来截去输入的日期值。忽略它则由最近的日期截去
下面是该函数的使用情况:
trunc(sysdate,'yyyy') --返回当年第一天.
trunc(sysdate,'mm') --返回当月第一天.
trunc(sysdate,'d') --返回当前星期的第一天.
 
TRUNC(89.985,2)=89.98
TRUNC(89.985)=89 (即取整)
TRUNC(89.985,-1)=80
 
-Oracle trunc()函数的用法
/**************日期********************/
1.select trunc(sysdate) from dual  --2011-3-18  今天的日期为2011-3-18
2.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  --2011-1-1   返回当年第一天
6.select trunc(sysdate,'d') from dual  --2011-3-13 (星期天)返回当前星期的第一天
7.select trunc(sysdate, 'hh') from dual   --2011-3-18 14:00:00   当前时间为14:41   
8.select trunc(sysdate, 'mi') from dual  --2011-3-18 14:41:00   TRUNC()函数没有秒的精确
/***************数字********************/
/*
TRUNC(number,num_digits) 
Number 需要截尾取整的数字。 
Num_digits 用于指定取整精度的数字。Num_digits 的默认值为 0。
TRUNC()函数截取时不进行四舍五入
*/
9.select trunc(123.458) from dual --123
10.select trunc(123.458,0) from dual --123
11.select trunc(123.458,1) from dual --123.4
12.select trunc(123.458,-1) from dual --120
13.select trunc(123.458,-4) from dual --0
14.select trunc(123.458,4) from dual  --123.458
15.select trunc(123) from dual  --123
16.select trunc(123,1) from dual --123
17.select trunc(123,-1) from dual --120

trunc函数的更多相关文章

  1. oracle的round函数和trunc函数

    --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...

  2. Oracle trunc()函数的用法

    Oracle trunc()函数的用法 /**************日期********************/1.select trunc(sysdate) from dual --2013-0 ...

  3. Oracle中trunc函数、round 函数、ceil函数和floor函数的使用

    Oracle中trunc函数.round 函数.ceil函数和floor函数的使用 1.1trunc函数处理数字 trunc函数返回处理后的数值,其工作机制与ROUND函数极为类似,只是该函数不对指定 ...

  4. 说说oracle的 sysdate、trunc函数

    SQL> select trunc(sysdate)+1/24+3 from dual; TRUNC(SYSDATE)+1/24-------------------2015-08-14 01: ...

  5. Oracle trunc函数

    --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual  --2011 ...

  6. oracle获取本月第一天和最后一天及Oracle trunc()函数的用法

    select to_char(trunc(add_months(last_day(sysdate), -1) + 1), 'yyyy-mm-dd') "本月第一天", to_cha ...

  7. Oracle trunc()函数

    Oracle trunc()函数的用法   --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysd ...

  8. Oracle trunc()函数的用法--来着心静禅定ing

    1.TRUNC(for dates) TRUNC函数为指定元素而截去的日期值. 其具体的语法格式如下: TRUNC(date[,fmt]) 其中: date 一个日期值 fmt 日期格式,该日期将由指 ...

  9. Oracle trunc() 函数处理数字、日期的整理

    --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...

随机推荐

  1. 设置viewport进行缩放

    <meta name="viewport" content="width=320,maximum-scale=1.3,user-scalable=no"& ...

  2. Generic Netlink详解

    netlink socket是一种用于用户态进程和内核态进程之间的通信机制.它通过为内核模块提供一组特殊的API,并为用户程序提供了一组标准的socket接口的方式,实现了全双工的通讯连接. Netl ...

  3. sdust 2410 Mine Number

    今天看了3个这种题了  枚举第一行即可 #include<cstdio> #include<cstring> #include<iostream> #include ...

  4. 21. Merge Two Sorted Lists

    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...

  5. HDU 1392 凸包

    Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  6. Codeforces Round #367 (Div. 2) A B C 暴力 二分 dp(字符串的反转)

    A. Beru-taxi time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  7. SQLITE LIMIT

    sqlite> create table t_user(userid int,username varchar(20)); sqlite> insert into t_user value ...

  8. Radiobutton编辑

    package com.example.yuekao3; import java.util.ArrayList;import java.util.List; import com.baidu.farm ...

  9. HDU 4497 数论+组合数学

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4497 解题思路:将满足条件的一组x,z,y都除以G,得到x‘,y',z',满足条件gcd(x',y' ...

  10. install kinect driver for ARM---38

    原创博客:转载请标明出处:http://www.cnblogs.com/zxouxuewei/ The video describes connecting a Microsoft Kinect to ...