简体   繁体   English

如何获取一周的第一天和最后一天的日期

[英]How to get the date of the first and last day of a week

I have this query who gives me the week number.我有这个查询谁给了我周数。

select to_char(sysdate, 'iw') week from dual

I would like to retrieve the first and last date, like this: 2019-11-11 to 2019-11-17.我想检索第一个和最后一个日期,如下所示:2019-11-11 到 2019-11-17。

Thank you.谢谢你。

I think the easiest way is to use trunc() :我认为最简单的方法是使用trunc()

select trunc(sysdate, 'iw') as week_start,
       trunc(sysdate, 'iw') + interval '6' day as week_end       
from dual

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM