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在当天的零时零分零秒等于trunc(sysdate) select trunc(sysdate, 'dd'), trunc(sysdate) from dual t; --今天 20140703 零时零分零秒
select to_char(trunc(sysdate, 'dd'), 'yyyy/mm/dd hh24:mi:ss'),
to_char(trunc(sysdate), 'yyyy/mm/dd hh24:mi:ss')
from dual; select trunc(sysdate-to_date('20140709 23:12:12','yyyy/mm/dd hh24:mi:ss')) from dual t;--两个日期相差的天数
select trunc(sysdate-1) from dual t;--昨天
select trunc(sysdate+1) from dual t;--明天 select trunc(sysdate, 'yy') from dual;--当年第一天
select trunc(sysdate, 'year') from dual;--当年第一天
select trunc(sysdate, 'yyyy') from dual;--当年第一天 select trunc(sysdate, 'q') from dual;--当前时间所在的季度的第一天 select trunc(sysdate, 'mm') from dual;--当月第一天
select trunc(sysdate, 'month') from dual;--当月第一天 select trunc(sysdate, 'd') from dual;--返回本周的第一天(周日为第一天)
select trunc(sysdate,'day') from dual;--返回本周的第一天(周日为第一天) select trunc(sysdate, 'iw') from dual;--本周第二天(周日为第一天) select trunc(sysdate, 'hh') from dual; --当前时间,精确到小时
select trunc(sysdate, 'hh24') from dual;--当前时间。精确到小时 select trunc(sysdate, 'mi') 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函数使用的更多相关文章

  1. Oracle trunc()函数的用法

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

  2. Oracle trunc函数

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

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

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

  4. Oracle trunc()函数

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

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

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

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

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

  7. Oracle trunc()函数的用法及四舍五入 round函数

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

  8. [转]Oracle trunc()函数的用法

    原文地址:http://www.cnblogs.com/gengaixue/archive/2012/11/21/2781037.html 1.TRUNC(for dates) TRUNC函数为指定元 ...

  9. Oracle trunc()函数,decode()函数,substr函数,GREATEST函数,java中substring函数的用法

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

  10. Oracle - Trunc() 函数截取日期&截取数值

    Oracle TRUNC函数可以截取数字和日期类型:截取日期:select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual; --显示当前时间 s ...

随机推荐

  1. php 关于锁的一些看法

    背景:在一个项目中,需要一次对数据很复杂的计算,其中一次计算需要花费大概30秒钟时间,大概需要查询一个比较大的表300次左右,然后还需要进行查询7-8次数据库,然后进行组合排序等功能,完成最终结果.对 ...

  2. socket多线程方式案例

    记下来,方便以后查看 User类 package com.xujingyang.ThreadSocket; import java.io.Serializable; public class User ...

  3. Halcon将裁剪后的图像还原为原始大小

    ************************************************************* * Halcon将裁剪后的图像还原为原始大小 * Author: LiGua ...

  4. R: 主成分分析 ~ PCA(Principal Component Analysis)

    本文摘自:http://www.cnblogs.com/longzhongren/p/4300593.html 以表感谢. 综述: 主成分分析 因子分析 典型相关分析,三种方法的共同点主要是用来对数据 ...

  5. Luogu 3479 [POI2009]GAS-Fire Extinguishers

    补上了这一道原题,感觉弱化版的要简单好多. 神贪心: 我们设$cov_{x, i}$表示在$x$的子树中与$x$距离为$i$的还没有被覆盖到的结点个数,设$rem_{x, i}$表示在$x$的子树中与 ...

  6. can基础知识介绍

    1.什么是can 2.can的特点 2.物理层特征 我们使用ISO11898标准,物理层特征如图所示 3.帧的种类介绍 实际上有一些帧是有硬件来实现的. 4.数据帧介绍 5.总线仲裁 6.位时序(用于 ...

  7. JavaScript中的Array.prototype.slice.call()方法学习

    JavaScript中的Array.prototype.slice.call(arguments)能将有length属性的对象转换为数组(特别注意: 这个对象一定要有length属性). 但有一个例外 ...

  8. 第4章 jQuery中的事件和动画

    4.1 jQuery中的事件 4.1.1 加载DOM jQuery就是用 `$(document).ready()方法来代替传统JavaScript的window.onload方法的. 1.执行时机 ...

  9. jQuery 基础 : 获取对象 根据属性、内容匹配, 还有表单元素匹配

    指定元素中包含 id 属性的, 如: $("span[id]")   <span id="span1" name="S1">AA ...

  10. ASP.NET常用数据绑定控件优劣总结

    本文的初衷在于对Asp.net常用数据绑定控件进行一个概览性的总结,主要分析各种数据绑定控件各自的优缺点,以便在实际的开发中选用合适的控件进行数据绑定,以提高开发效率. 因为这些数据绑定控件大部分都已 ...