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

引用:https://www.cnblogs.com/zfyouxi/p/5236336.html

trunc()的更多相关文章

  1. Oracle中trunc()函数用法

    SQL表达式 注释 SELECT SYSDATE FROM dual --当前系统时间,24小时制 SELECT TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss') FR ...

  2. 以下C#程序的输出结果是( )。

    以下程序的输出结果是( ). using System; namespace HoverTreeTikuConsole { class Program { static void Main(strin ...

  3. PHP 位运算(&, |, ^, ~, <<, >>)及 PHP错误级别报告设置(error_reporting) 详解

    位运算符允许对整型数中指定的位进行求值和操作. 位运算符 例子 名称 结果 $a & $b And(按位与) 将把 $a 和 $b 中都为 1 的位设为 1. $a | $b Or(按位或) ...

  4. 页面加载完成后,触发事件——trigger()

    <button id="btn">点击我</button> <div id="test"></div> 如果页面 ...

  5. linux/unix 编程手册 fork()函数

    父进程通过fork()函数创建子进程,将父进程数据段和栈的内容拷贝到子进程中,子进程执行程序execve创建新程序,调用exit函数退出到等待wait(),挂起父进程, 父子进程享用相同的程序文本段. ...

  6. setInterval()与clearInterval()的一个有趣小现象

    今天在使用setInterval()时,发现了一个有意思的事情 代码如下: var box=document.getElementById("box");//获取id为“box”的 ...

  7. HTML DOM对象之createElement()方法

    今天在学习DOM节点操作时,发现了创建DOM节点的createElement()方法的一个有意思的现象. 代码如下: var box=document.getElementById("box ...

  8. join()方法之我见

    JavaScript join() 方法 定义和用法 join() 方法用于把数组中的所有元素放入一个字符串. 元素是通过指定的分隔符进行分隔的. 语法 arrayObject.join(separa ...

  9. 转义字符(\)对JavaScript中JSON.parse的影响概述

    JSON是一个提供了stringify和parse方法的内置对象,前者用于将js对象转化为符合json标准的字符串,后者将符合json标准的字符串转化为js对象,本文为大家介绍下转义字符对JSON.p ...

随机推荐

  1. bootstrap学习笔记(网页开发小知识)

    这是我在学习Boostrap网页开发时遇到的主要知识点: 1.导航条navbar 添加.navbar-fixed-top类可以让导航条固定在顶部,固定的导航条会遮住页面上的其他内容,除非给<bo ...

  2. Java 开源博客 Solo 1.6.0 发布 - 新后台

    简介 Solo 是一款一个命令就能搭建好的 Java 开源博客系统,并内置了 15+ 套精心制作的皮肤.除此之外,Solo 还有着非常活跃的社区,文章分享到社区后可以让很多人看到,产生丰富的交流互动. ...

  3. LintCode2016年8月8日算法比赛----等价二叉树

    等价二叉树 题目描述 检查两棵二叉树是否等价.等价意思是说,首先两棵二叉树必须拥有相同的结构,并且每个对应位置上的节点上的数据相等. 样例 1 1 / \ / \ 2 2 and 2 2 / / 4 ...

  4. JavaScript : Array assignment creates reference not copy

    JavaScript : Array assignment creates reference not copy 29 May 2015 Consider we have an array var a ...

  5. SSM 框架-06-详细整合教程(IDEA版)(Spring+SpringMVC+MyBatis)

    SSM 框架-06-详细整合教程(IDEA版)(Spring+SpringMVC+MyBatis) SSM(Spring.Spring MVC和Mybatis)如果你使用的是 Eclipse,请查看: ...

  6. 使用ZXing实现扫描多个条形码页面

    1.前言 ZXing是google官方推出的跨平台的基于Java实现处理扫面二维码或者条形码的库.支持很多格式,一维条码支持UPC-A,UPC-E,EAN-8,Code 39,Code 93等格式,二 ...

  7. mysql DML语句学习1

    DML 操作是指对数据库中表记录的操作,主要包括表记录插入(insert).更新(update).删除(delete)和查询(select) 1. 插入记录 表创建好后,就可以往里插入记录,基本语句如 ...

  8. December 10th 2016 Week 50th Saturday

    Storms make trees take deeper roots. 风暴使树木深深扎根. Sometimes, you may feel frustrated for failing to wi ...

  9. Linux基础入门 - 3

    第四节 Linux 目录结构及文件基本操作 4-1.Linux目录结构 Linux 的目录与 Windows 的目录的实现机制是完全不同的.一种不同是体现在目录与存储介质(磁盘,内存,DVD 等)的关 ...

  10. GET POST 传值与接收案例

      第一种:GET传递 前台 ajax   GET 传递 :即在请求的地址后面加上参数,URL地址长度有显示,安全性低 后台接收:Request.QueryString[“参数名字”]! 例如: fu ...