如何在 Oracle 中获取一周的第一天和最后一天? [英] How to get first and last day of week in Oracle?

查看:175
本文介绍了如何在 Oracle 中获取一周的第一天和最后一天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一些格式如下的字符串中获取一周的第一天和最后一天:

I need to get the first day and the last day of the week from some strings that have the format like this:

'201118'

其中 2011 是年份,18 是周数.知道星期几,怎么得到一周的第一天和最后一天?

where 2011 is the year and 18 is the number of the week. Knowing the number of the week, how do I get the first and the last day of the week?

我该怎么做?

推荐答案

WEEK

select TRUNC(sysdate, 'iw') AS iso_week_start_date,
       TRUNC(sysdate, 'iw') + 7 - 1/86400 AS iso_week_end_date
from dual;

select 
TRUNC (sysdate, 'mm') AS month_start_date,
LAST_DAY (TRUNC (sysdate, 'mm')) + 1 - 1/86400 AS month_end_date
from dual;

这篇关于如何在 Oracle 中获取一周的第一天和最后一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆