oracle获取上一旬的开始时间和结束时间的实现函数
to_char(last_day(add_months(v_rq, -1)) + 1 - 1 / 24 / 60 / 60,
to_char(add_months(v_rq, -1), 'yyyyMM') || '21'
into refstr
from dual;
-- 这个获取的是:上旬的结束日期
select fd_lastxunend(to_date('20130311','yyyymmdd')) from dual;
return refstr;
select fd_lastxunend(sysdate) from dual;
end fd_lastxunend;
select last_day(add_months(trunc(sysdate), -1)) from dual;
select fd_lastxunstart(to_date('20130311','yyyymmdd')) from dual;
v_rq := trunc(rq);
select case decode(trunc((to_char(v_rq, 'dd') - 1) / 10),
复制代码 代码如下:
into refstrv_rq := trunc(rq);
'下旬')
v_rq date;
-- 执行结果为: 2013/9/5 12:08:39、20130821、20130221、20130301、20130311
-- 观察 1 / 24 / 60 / 60 的作用 这个是一秒
--获取上一旬的日期
select case decode(trunc((to_char(v_rq, 'dd') - 1) / 10),
end
end
---- 获取上一旬的结束日期
0,
select fd_lastxunend(to_date('20130305','yyyymmdd')) from dual;
to_char(v_rq, 'yyyymm') || '11'
to_char(v_rq, 'yyyymm') || '01' else
refstr varchar2(50);
select fd_lastxunend(to_date('20130315','yyyymmdd')) from dual;
-- 这个返回的是:上旬的开始日期
refstr varchar2(50);
v_rq date;
select fd_lastxunend(to_date('20130221','yyyymmdd')) from dual;
select last_day(add_months(trunc(sysdate), -1)) + 1 - 1 / 24 / 60 / 60
--chr(39) 这个是加引号
end fd_lastxunstart;
select sysdate from dual;
-- 获取上旬开始时间
return refstr;
'上旬',
select fd_lastxunstart(to_date('20130305','yyyymmdd')) from dual;
begin
select last_day(add_months(trunc(sysdate), -1)) + 1 from dual;
'上旬',
1,
when '上旬' then --返回上个月的下旬
from dual;
--获取上一旬的日期
-- 执行结果:2013/8/31 23:59:59、2013/8/31、2013/9/1
begin
-- 传递进去 一个 date 类型的值,返回一个varchar类型的上旬结束日期
select fd_lastxunstart(to_date('20130325','yyyymmdd')) from dual;
0,
--执行结果:20130831、20130228、20130310、20130310、20130220
to_char(v_rq, 'yyyymm') || '10' else
when '中旬' then
'下旬')
'中旬',
when '上旬' then --返回上个月的最后1天
to_char(v_rq, 'yyyymm') || '20'
'中旬',
create or replace function fd_lastxunend(rq in date) return string is
create or replace function fd_lastxunstart(rq in date) return string is
select fd_lastxunstart(sysdate) from dual;
'yyyymmdd')
1,
from dual;
相关热词: oracle
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/sql/oracle/2543.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
是因为scan的IP问题补占用
时间:2021-01-20
-
还你一个干净的model 2、功
时间:2021-01-20
-
既然 ROWNUM 列并不是真实存
时间:2021-01-20
-
Real Application Clusters
时间:2021-01-20
-
在tools-preferences-connection(
时间:2021-01-20
-
Windows Sever 2012下Oracle 12c安
时间:2021-01-10
-
Oracle安装监听器错误的解
时间:2021-01-07
-
oracle远程连接服务器数据
时间:2021-01-07
热门文章
-
Oracle存储过程编程详解
时间:2020-12-07
-
Azure Queue Storage 基本用法 Azure Storage 之
时间:2020-12-26
-
win10下oracle 11g安装图文教程
时间:2020-12-25
-
oracle 数据库学习 基本结构介绍
时间:2020-12-13
-
Azure File Storage 基本用法 Azure Storage 之 F
时间:2020-12-26
-
windows使用sqlpus连接oracle 数据库的教程图
时间:2020-12-25
-
Window下Oracle Database 11g 发行版2安装教程
时间:2020-12-29
-
Oracle解锁的方式介绍
时间:2020-12-14
-
Oracle 12c Study之Installer Oracle
时间:2021-01-06
-
linux下oracle设置开机自启动实现方法
时间:2020-12-13
