Home > Database > Mysql Tutorial > body text

Oracle 取得当天0时0分0秒和23时59分59秒

WBOY
Release: 2016-06-07 17:02:58
Original
2111 people have browsed it

1. 取得当天0时0分0秒 select TRUNC(SYSDATE) FROM dual; 2. 取得当天23时59分59秒(在当天0时0分0秒的基础上加1天后再减1秒) SEL

1. 取得当天0时0分0秒

select TRUNC(SYSDATE) FROM dual;

2. 取得当天23时59分59秒(在当天0时0分0秒的基础上加1天后再减1秒)

SELECT TRUNC(SYSDATE)+1-1/86400 FROM dual;

3.取得当前日期是一个星期中的第几天,注意:星期日是第一天

select to_char(sysdate,'D'),to_char(sysdate,'DAY') from dual;

4. 在Oracle中如何得到当天月份的第一天和最后一天

select to_char(sysdate,'yyyy-mm')||'-01' firstday,to_char(last_day(sysdate),'yyyy-mm-dd') lastday from dual

5.实现当天16点前数据减去昨天16点的,过了16点减去今天16点

select field1, field2 from mytablewhere time = decode(sign(sysdate-trunc(sysdate)-16/24), --时间判断                    

-1,trunc(sysdate)-1+16/24, --小于16点取昨天16点                       

trunc(sysdate)+16/24)  --大于16点取当天16点

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!