oracle trunc函数用法
转自:https://www.e-learn.cn/content/qita/699481
/**************日期********************/
select trunc(sysdate) from dual ;--2011-3-18 今天的日期为2011-3-18
select 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 add_months(to_date('2018-01-01','yyyy-mm-dd'),12)-1 from dual; -- 2018-12-31 返回当年第一天
select trunc(sysdate,'d') from dual ; --2011-3-13 (星期天)返回当前星期的第一天
select trunc(sysdate, 'hh') from dual ; --2011-3-18 14:00:00 当前时间为14:41
select trunc(sysdate, 'mi') from dual ; --2011-3-18 14:41:00 TRUNC()函数没有秒的精确
SELECT to_date('20180818','yyyymmdd')-to_date('20180727','yyyymmdd') 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函数用法的更多相关文章
- Oracle trunc()函数的用法
Oracle trunc()函数的用法 /**************日期********************/1.select trunc(sysdate) from dual --2013-0 ...
- oracle获取本月第一天和最后一天及Oracle trunc()函数的用法
select to_char(trunc(add_months(last_day(sysdate), -1) + 1), 'yyyy-mm-dd') "本月第一天", to_cha ...
- Oracle trunc()函数的用法--来着心静禅定ing
1.TRUNC(for dates) TRUNC函数为指定元素而截去的日期值. 其具体的语法格式如下: TRUNC(date[,fmt]) 其中: date 一个日期值 fmt 日期格式,该日期将由指 ...
- Oracle trunc()函数的用法及四舍五入 round函数
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2011 ...
- [转]Oracle trunc()函数的用法
原文地址:http://www.cnblogs.com/gengaixue/archive/2012/11/21/2781037.html 1.TRUNC(for dates) TRUNC函数为指定元 ...
- Oracle trunc()函数,decode()函数,substr函数,GREATEST函数,java中substring函数的用法
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...
- Oracle trunc函数
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2011 ...
- Oracle trunc()函数
Oracle trunc()函数的用法 --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysd ...
- Oracle trunc() 函数处理数字、日期的整理
--Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...
随机推荐
- 004-行为型-10-中介者模式(Mediator)
一.概述 在Mediator模式中,类之间的交互行为被统一放在Mediator的对象中,对象通过Mediator对象同其他对象交互,Mediator对象起着控制器的作用. 用一个中介对象来封装一系列的 ...
- python import注意事项
# 基本概念 ## 模块&包简介 模块:所谓模块就是一个.py文件,用来存放变量,方法的文件,便于在其他python文件中导入(通过import或from).包(package): 包是更大的 ...
- MySQL数据库双机热备------主-主备份配置
MySQL数据库双机热备------主-主备份配置 实验环境: 主1数据库 192.168.1.1 centos6.5 x86_64 +MySQL5.5.35 主2数据库192.168.1.2 Wi ...
- bat函数调用 带返回值
bat 脚本之 使用函数 摘自:https://blog.csdn.net/peng_cao/article/details/73999076 综述 bat函数写法 bat函数调用 bat函数返回值 ...
- T-SQL_常用内置函数和操作
作者:icyjiang 推荐:LinkEdu SELECT --从数据库表中检索数据行和列 INSERT --向数据库表添加新数据行 DELETE --从数据库表中删除数据行 UPDATE --更新数 ...
- 【JQuery插件】扑克正反面翻牌效果
里面有两个demo,支持X横向和Y纵向翻转两个效果. 对元素的布局有一定的讲究,需要分析一下demo的css. 默认翻转速度为80,不要大于100ms. <!DOCTYPE> <ht ...
- Gitlab提交时间错误问题修复
gitlab-ctl status gitlab提交时间显示错误,明明是近期修改提交的代码在页面显示的时间是19年前 查看配置文件 /etc/gitlab/gitlab.rb 时区设置正确,再说就算是 ...
- Linux终极shell-zsh的完美配置方案!——oh-my-zsh
Zsh 介绍 Zsh 兼容 Bash,据传说 99% 的 Bash 操作 和 Zsh 是相同的 Zsh 官网:http://www.zsh.org/ 先看下你的 Linux支持哪些 shell:cat ...
- nginx配置访问本地静态资源
下面说说如何在windows下使用nginx作为静态资源服务器, 1.修改config目录下,这个配置文件,基本上所有的配置都在这里面做, 2.主要的配置参数如下,一些无关的参数我直接去掉了,注意,里 ...
- VMware虚拟机及Linux安装
VMware虚拟机安装指南:http://bbs.luobotou.org/thread-5750-1-1.html Linux系统各发行版镜像下载地址:http://www.linuxidc.com ...