当前位置:网站首页>sql 时间处理(SQL SERVER\ORACLE)
sql 时间处理(SQL SERVER\ORACLE)
2022-07-27 16:28:00 【黑暗料理界的扛把子】
1、获取当前时间
#dtbegindate : 数据库内时间
#extract(MONTH FROM dtbegindate) :获取dtbegindate 内的月份
#to_char (sysdate, 'yyyy-MM-dd') : 获取当前时间并转换为固定格式字符类型
#to_date (to_char (sysdate, 'yyyy-MM-dd'),'yyyy-mm-dd'): 获取当前时间并转换为时间格式
#sysdate :获取当前时间
SELECT
dtbegindate,
extract(MONTH FROM dtbegindate),
to_char (sysdate, 'yyyy-MM-dd'),
CASE
WHEN to_date (
to_char (sysdate, 'yyyy-MM-dd'),
'yyyy-mm-dd'
) > dtbegindate THEN
1
ELSE
0
END AS todatetime,
sysdate,
CASE
WHEN sysdate > dtbegindate THEN
1
ELSE
0
END AS nowtime
FROM
bs_class2、获取当前时间的月份
年 select extract(year from sysdate) from dual;
月 select extract(month from sysdate) from dual;
日 select extract(day from sysdate) from dual;3、oracle中如何获得日期中的年份
select
to_number(to_char(t.hiredate,'yyyy'))as 入职年,
to_number(to_char(t.hiredate,'MM'))as 入职月,
to_number(to_char(t.hiredate,'DD'))as 入职天
from emp t;4、sql server
#获取指定的时间内的月、年
month(c.dtDate)
year(c.dtDate)
#将时间变为varchar
CONVERT(varchar(100), c.dtDate, 23)
边栏推荐
- Latex use - control the display position of tables or graphics
- Unity display Kinect depth data
- IDEA连接数据库时区问题,报红Server returns invalid timezone. Need to set ‘serverTimezone‘ property.
- Docker - docker installation, MySQL installation on docker, and project deployment on docker
- MongoDB学习笔记(1)——安装MongoDB及其相关配置
- Selenium自动化测试面试题全家桶
- express
- Code interview of Amazon
- express
- IDEA成功连接Database但不显示表怎么办
猜你喜欢

MySQL learning notes (2) -- stored procedures and stored functions

JMeter interface automation - how to solve the content type conflict of request headers

Self control principle learning notes - system stability analysis (1) - BIBO stability and Routh criterion

v-if,v-else,v-for

CMD command

`this.$emit` 子组件给父组件传递多个参数

2022备战秋招10W字面试小抄pdf版,附操作系统、计算机网络面试题

Redis annotation

Product recommendation and classified product recommendation

Kinect2 for unity3d - avatardemo learning
随机推荐
Some advice for NS2 beginner.
自控原理学习笔记-系统稳定性分析(2)-环路分析及Nyquist-Bode判据
IDEA成功连接Database但不显示表怎么办
v-if,v-else,v-for
WPS turns off annoying advertisements
WSN Journal indexed by SCI(转)
Unity学习笔记——物体移动六种常见函数
Kinect for Unity3d----KinectManager
Selenium automated test interview questions family bucket
ES6 new method
MySQL learning notes (2) -- stored procedures and stored functions
【云图说】 第250期 初识华为云微服务引擎CSE
NPM's ID card and dependence
MySQL 05 stored procedure
Using functions to extract numbers from text strings in Excel
Express get/post/delete... Request
PHP字符串操作
Summary of "performance test" of special test
log4j. Properties log details
During the interface test, connect to the database and back up, restore and verify the data source