当前位置:网站首页>【Oracle 数据库】奶妈式教程 day13 日期函数
【Oracle 数据库】奶妈式教程 day13 日期函数
2022-06-22 07:52:00 【菜鸟进阶站】
日期函数
1、SYSDATE 返回当前系统的本地时间
SELECT SYSDATE FROM dual;

SELECT SYSDATE,
SYSDATE + 1,
SYSDATE + 1/24,
SYSDATE + 1/24/60,
SYSDATE + 1/24/60/60 FROM DUAL;

日期的运算
日期 + 或者 - 数 = 天数
日期 - 日期 = 相差的天数
注意:
不能 日期+日期
SELECT SYSDATE - (SYSDATE - 1) FROM dual;

2、add_months(日期1,数)
SELECT SYSDATE,ADD_MONTHS(SYSDATE,13) FROM DUAL;

3、months_between(日期1,日期2)求两个日期相差的月数
SELECT months_between(DATE '1999-09-09',SYSDATE) FROM dual;

相差月数除以12 = 相差年数
4、next_day(日期,数字) 求下个周几 (数字代表周几)
SELECT NEXT_DAY(SYSDATE,6)FROM DUAL;

1代表周7
2代表周1
3代表周2
4代表周3
5代表周4
6代表周5
7代表周6
5、last_day(日期)返回当前日期所在月份的最后一天
SELECT LAST_DAY(SYSDATE) FROM DUAL;

6、TRUNC(日期,'格式') 截断到日期之初
SELECT TRUNC(SYSDATE,'DY') FROM DUAL;

yyyy 年
mm 月
dd 日
hh 时
mi 分
SS 秒
q 一季之初
DAY/dy 一周之初
hh24
边栏推荐
- Ugui text spacing textspacing
- Asynchronous sending and receiving of message passing based concurrent programming (MPI)
- 网站的排名对于网站很重要
- White paper on Web page quality of Baidu search engine guides website construction and optimization
- New year's Day mall material Icon
- What are uniapp, wap2app and 5 + app in dccloud?
- lr 2022超详细安装教程「最新」
- Crmeb open source version, a free mall worth trying
- Layer drawing method
- 7、 Picker component
猜你喜欢

Vue failed to connect to MySQL database

Target detection series -- detailed explanation of RCNN principle

mysql查询group by 1055 问题完美解决,最简单最便捷的方法

目标检测系列——开山之作RCNN原理详解

Crmeb mall order shipping function

What is distributed transaction

Remote Desktop Manager

丰田bZ4X取消上市发布会,就算低温充电问题不存在,产品力如何?

(7)双向链表

Canvastotempfilepath of wechat
随机推荐
LR 2022 ultra detailed installation tutorial "latest"
MySQL intercepts the string cs0000_ 1 medium_ Following characters
Modular import and export collation in JS
7、 Picker component
Windchill - how to start workflow through API
8、 Slider assembly
Toyota bz4x canceled the launch conference. Even if the low-temperature charging problem does not exist, how about the product strength?
[multi thread programming] thread scheduling strategy and priority
网站的日常维护
Cocoapods problem record
Wechat games (3)
充电宝的玄机
目标检测系列——开山之作RCNN原理详解
Cocoapods creates private libraries and publishes them
对于mysql中数据为NULL引发的一些问题和思考
The ranking of websites is very important for websites
Itemtools permutation
9、 Textinput component
Concurrent programming summary
Open source get through version - integral function