最新活动:电脑PC端+手机端+微网站+自适应网页多模板选择-建站388元起价!!!
当前位置:主页 > 网站建设 > oracle获取上一旬的开始时间和结束时间的实现函

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

时间:2023-05-22 21:05:22 阅读: 文章分类: 网站建设 作者: 网络小编

导读:1建站知识本文为大家介绍下oracle如何获取上一旬的开始时间和结束时间,实现函数如下,感兴趣的朋友可以参考下如何seo优化推广网站seo网站优化软件。

如何seo优化推广网站seo网站优化软件

复制代码 代码如下:

-- 获取上旬开始时间 create or replace function fd_lastxunstart(rq in date) return string is refstr varchar2(50); v_rq date; begin --获取上一旬的日期 v_rq := trunc(rq); select case decode(trunc((to_char(v_rq, 'dd') - 1) / 10), 0, '上旬', 1, '中旬', '下旬') when '上旬' then --返回上个月的下旬 to_char(add_months(v_rq, -1), 'yyyyMM') || '21' when '中旬' then to_char(v_rq, 'yyyymm') || '01' else  to_char(v_rq, 'yyyymm') || '11' end into refstr from dual; return refstr; end fd_lastxunstaseo网站优化rt; -- 这个返回的是:上旬的开始日期 select sysdate from dual;seo网站关键词优化 select fd_lastxunstart(sysdate) from dual; select fd_lastxunstart(to_date('20130305','yyyymmdd')) from dual; select fd_lastxunstart(to_date('20130311','yyyymmdd')) from dual; select fd_lastxunstart(to_date('20130325','yyyymmdd')) from dual; -- 执行结果为: 2013/9/5 12:08:39、20130821、20130221、20130301、20130311 ---- 获取上一旬的结束日期 -- 传递进去 一个 date 类型的值,返回一个varchar类型的上旬结束日期 create or replace function fd_lastxunend(rq in date) return string is refstr varchar2(50); v_rq date; begin --获取上一旬的日期 v_rq := trunc(rq); select case decode(trunc((to_char(v_rq, 'dd') - 1) / 10), 0, '上旬', 1, '中旬', '下旬') when '上旬' then --返回上个月的最后1天 --chr(39) 这个是加引号 to_char(last_day(add_months(v_rq, -1)) + 1 - 1 / 24 / 60 / 60, 'yyyymmdd') when '中旬' then to_char(v_rq, 'yyyymm') || '10' else  to_char(v_rq, 'yyyymm') || '20' end into refstr from dual; return refstr; end fd_lastxunend; -- 这个获取的是:上旬的结束日期 select fd_lastxunend(sysdate) from dual; select fd_lastxunend(to_date('20130305','yyyymmdd')) from dual; select fd_lastxunen网seo优化趋势d(to_date('20130311','yyyymmdd')) from dual; select fd_lastxunend(to_date('20130315','yyyymmdd')) from dual; select fd_lastxunend(to_date('20130221','yyyymmdd')) from dual; --执行结果:20130831、20130228、20130310、20130310、20130220 -- 观察 1 / 24 / 60 / 60 的作用 这个是一秒 select last_day(add_months(trunc(sysdate), -1)) + 1 - 1 / 24 / 60 / 60 from dual; select last_day(add_months(trunc(sysdate), -1)) from dual; select last_day(add_months(trunc(sysdate), -1)) + 1 from dual; -- 执行结果:2013/8/31 23:59:59、2013/8/31、2013/9/1

相关如何seo优化推广网站seo网站优化软件。

关键词标签: 函数 上一

声明: 本文由我的SEOUC技术文章主页发布于:2023-05-22 ,文章oracle获取上一旬的开始时间和结束时间的实现函主要讲述上一,函数,oracle获取上一旬的开始时间和结束时间网站建设源码以及服务器配置搭建相关技术文章。转载请保留链接: https://www.seouc.com/article/web_5285.html

我的IDC 网站建设技术SEOUC.COM
专注网站建设,SEO优化,小程序设计制作搭建开发定制网站等,数千家网站定制开发案例,网站推广技术服务。
  • 5000+合作客服
  • 8年从业经验
  • 150+覆盖行业
  • 最新热门源码技术文章