当前位置:网站首页>SQL time processing (SQL server\oracle)
SQL time processing (SQL server\oracle)
2022-07-27 19:20:00 【The bearer of dark cuisine】
1、 Get the current time
#dtbegindate : Time in database
#extract(MONTH FROM dtbegindate) : obtain dtbegindate Months in
#to_char (sysdate, 'yyyy-MM-dd') : Get the current time and convert it to fixed format character type
#to_date (to_char (sysdate, 'yyyy-MM-dd'),'yyyy-mm-dd'): Get the current time and convert it to time format
#sysdate : Get the current time
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、 Get the month of the current time
year select extract(year from sysdate) from dual;
month select extract(month from sysdate) from dual;
Japan select extract(day from sysdate) from dual;3、oracle How to get the year in the date
select
to_number(to_char(t.hiredate,'yyyy'))as Year of entry ,
to_number(to_char(t.hiredate,'MM'))as Entry month ,
to_number(to_char(t.hiredate,'DD'))as Days of employment
from emp t;4、sql server
# Get the month within the specified time 、 year
month(c.dtDate)
year(c.dtDate)
# Change time into varchar
CONVERT(varchar(100), c.dtDate, 23)
边栏推荐
- 连续时间系统的性能分析(2)-二阶系统性能改善方式PID,PR
- asp. Net experience
- Kinect for Unity3d----KinectManager
- kettle switch / case 控件实现分类处理
- 连续时间系统的性能分析(1)-控制系统性能指标及一二阶分析
- Opening and using Alibaba cloud object storage OSS
- win10小技巧(1)——转移桌面位置
- 微机原理学习笔记-常见寻址方式
- C#与Mysql数据库交互-Mysql配置及增删查改操作
- Using vscode to build u-boot development environment
猜你喜欢

Technology Summit 58 Liu Yuan in the same city was invited to attend qecon 2022 global software quality & effectiveness conference

Basic use of Nacos (1) - getting started

C#与Mysql数据库交互-Mysql配置及增删查改操作

kettle引用外部脚本完成电话号码清洗、去重缩进

「测试新手百科」5 分钟快速上手Pytest 自动化测试框架

Using vscode to build u-boot development environment

Nacos的基本使用(1)——入门

200 lines of code quick start document database monogodb

MySQL 02 initial experience

Unity shows Kinect captured shots
随机推荐
Introduction to assembly language (1)
Memory management A4
mysql学习笔记(1)——变量
kettle switch / case 控件实现分类处理
一篇让你掌握线程和线程池,还解决了线程安全问题,确定不看看?
Latex use - subfigure vertical graphics
webservice的疑问
连续时间系统的性能分析(2)-二阶系统性能改善方式PID,PR
ref 关键字的用法
2022 preparation for autumn recruitment 10W word interview sketch PDF version, with operating system and computer network interview questions
C language case: password setting and login > clear solution getchar and scanf
The understanding of string in C.
asp.net 的经验
IDEA成功连接Database但不显示表怎么办
web UI 自动化测试:Selenium 语法详解 史上最全
每日一题(02):倒置字符串
Kinect2 for Unity3D——AvatarDemo学习
汇编语言入门基础(1)
浅谈基本的网络基本故障和问题排查
SSM integration