oracle

推荐列表 站点导航

当前位置:首页 > 数据库 > oracle >

oracle获取上一旬的开始时间和结束时间的实现函数

来源:网络整理  作者:网络  发布时间:2020-12-11 11:42
本文为大家介绍下oracle如何获取上一旬的开始时间和结束时间,实现函数如下,感兴趣的朋友可以参考下...
when '中旬' then
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 refstr
v_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

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

oracle获取上一旬的开始时间和结束时间的实现函数

2020-12-11 编辑:网络

when '中旬' then
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 refstr
v_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;

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/sql/oracle/2543.shtml

相关文章

风云图片

推荐阅读

返回oracle频道首页