Oracle Date Function 讲解和事例
1 year=1*12 months
1 day=24 hours=24*(1*60mins)=24*60*(1*60 seconds)
1 week =7 days
oracle 8i,9i都可以使用的函数,
Oracle9i新增的部分。
current_timestamp
datimezone
months_between
next_day
round
SYSDATE
trunc()
函数 -- n可正可负
B:上个月的今天
select add_months(sysdate,-1) from dual --在月份上减少
C: 上个月的最后一天
select last_day(add_months(sysdate,-1)) from dual
Current_date
oracle time_zone 是和系统Time_zone 一致。
--------------- ---------------
20051109 160535 20051109 160534
--------------- ---------------
20051109 20051109 160644
CURRENT_TIMESTAMP from dual;
------------------------------------------------------------
09-NOV-05 04.27.41.416811 PM +08:00
B: use precision
CURRENT_TIMESTAMP FROM DUAL
SESSIONTIMEZONE CURRENT_TIMESTAMP
-------------------- ---------------------------------------
-05:00 09-NOV-05 03.33.32.595277 AM -05:00
C: You can user others date funtion on
current_timestamp
SQL> select to_char(current_timestamp,'YYYYMMDD')
from dual;
-----------------------------------------------
2005
B:
------------------------------------------------
11
--------- --------- ----------
10-NOV-05 30-NOV-05 20
select months_between(sysdate-3,sysdate) "相差月数",
相差天数
-.09677419 -3 (11 月只有30 天)
2 BST, BDT: Bering Standard or Daylight Time
3 CST, CDT: Central Standard or Daylight Time
4 EST, EDT: Eastern Standard or Daylight Time
5 GMT: Greenwich Mean Time
6 HST, HDT: Alaska-Hawaii Standard Time or Daylight Time.
7 MST, MDT: Mountain Standard or Daylight Time
8 NST: Newfoundland Standard Time
9 PST, PDT: Pacific Standard or Daylight Time
10 YST, YDT: Yukon Standard or Daylight Time
------------------- -------------------
2005-11-10 06:24:06 2005-11-10 10:24:06
--------------------------
05-11-14 10:48:01
FROM DUAL;
本月的第一天
select trunc(sysdate,'month') from dual
select trunc(sysdate,'year') from dual
本月的最后一天
select last_day(sysdate) from dual
本周的第一天
select trunc(sysdate,'day') from dual --Oracle default start week is Sunday
select trunc(sysdate,'iw') from dual ---ISO year default start week is Monday
本周的星期一
select trunc(sysdate,'day')+1 from dual --2,3,4,5,6,
------
+00:00
This Month
----------
11
SQL> select extract(year from add_months sysdate,36)) "3 Years Out" from dual;
3 Years Out
-----------
2009
Oracle Date Function 讲解和事例的更多相关文章
- Oracle Table Function
Oracle Table Function在Oracle9i时引入.完美的兼容了view和存储过程的长处: 应用举例: 1.Table()函数: set feedback off create or ...
- oracle的function和procedure返回值给shell
本文演示两个关于如何在shell中调用oracle的function和procedure,并将返回值返回给shell. 1.首在package中创建function和procedure,脚本如下: G ...
- Oracle date timestamp 毫秒 - 时间函数总结(转)
原文地址:Oracle date timestamp 毫秒 - 时间函数总结 yyyy-mm-dd hh24:mi:ss.ff 年-月-日 时:分:秒.毫秒 --上一月,上一年select add_ ...
- [转载]oracle游标概念讲解
原文URL:http://www.2cto.com/database/201203/122387.html ORACLE游标概念讲解 什么是游标? ①从表中检索出结果集,从中每次指向一条记录进行交互 ...
- java中从1970-1-1到当前时间之间的毫秒数转换为oracle date
java中System.currentTimeMillis()取到的是从1970-01-01 00:00:00.000到当前时间的毫秒数,一个long类型的值. 现在oracle数据库中某表中存取的是 ...
- Oracle SYS_CONTEXT Function
Version 11.1 Actions As SYS Note: USERENV is an Oracle provided namespace that describes the curre ...
- oracle date函数
常用的时间格式 在oracle中有 yyyy-mm-dd hh24:mi:ss 而在Java中有些区别 为yyyy-MM-dd HH:mm:ss 这点还是经常容易模糊的.相信很多人都有过统计某些数据 ...
- Oracle date 和 timestamp 区别
1.DATE数据类型 这个数据类型我们实在是太熟悉了,当我们需要表示日期和时间的话都会想到date类型.它可以存储月,年,日,世纪,时,分和秒.它典型地用来表示什么时候事情已经发生或将要发生. ...
- PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone
在用PHP5.3以上的PHP版本时,只要是涉及时间的会报一个 Warning: phpinfo() [function.phpinfo]: It is not safe to rely on the ...
随机推荐
- c语言入门教程
https://www.youtube.com/playlist?list=PLY_qIufNHc293YnIjVeEwNDuqGo8y2Emx 感觉这个教程不错
- cv 验证
This is how I have trained a xgboost classifier with a 5-fold cross-validation to optimize the F1 sc ...
- oracle 序列初始化的plsql块脚本
declare seq_name dba_sequences.SEQUENCE_NAME%TYPE; cursor mycur is select * from dba_sequences where ...
- 当this指针成为指向之类的基类指针时,也能形成多态
this指针: 1)对象中没有函数,只有成员变量 2)对象调用函数,通过this指针告诉函数是哪个对象自己谁. #include<iostream> using namespace std ...
- win7桌面鼠标右键过慢的解决方案
由于Intel显卡驱动在桌面右键的加载项造成.解决方案:清理注册表中桌面右键加载项,点击开始,输入regedit,找到HKEY_CLASSES_ROOT\Directory\Background\sh ...
- EasyUI学习笔记(1)----Tree控件实现过程中.NET下无法访问json数据的解决办法
直接调用官网的Demo中的方法 , 将json数据存储在同目录下,但是在运行之后树没有出现,用FireBug调试,错误如下 不允许访问json数据,刚开始以为是权限不够,然后又给解决方案所在的文件夹设 ...
- MySQL性能调优与架构设计——第4章 MySQL安全管理
第4章 MySQL安全管理 前言 对于任何一个企业来说,其数据库系统中所保存数据的安全性无疑是非常重要的,尤其是公司的有些商业数据,可能数据就是公司的根本,失去了数据的安全性,可能就是失去了公司的一切 ...
- Nginx禁止直接通过IP地址访问网站
介绍下在nginx服务器禁止直接通过IP地址访问网站的方法,以避免别人恶意指向自己的IP,有需要的朋友参考下. 有时会遇到很多的恶意IP攻击,在Nginx下可以禁止IP访问. Nginx的默认虚拟主机 ...
- 将“100px” 转换为100
parseInt("100px") //结果是100
- Android 画个电池出来(Paint和canvas)
1.Android中很多时候都要自己去画一个自定义控件出来,就需要用到Paint和Canvas这两个类. 2.效果图: