Oracle:如何查找该月的最后一个星期五的日期 [英] Oracle: How to find date of last Friday of the month
本文介绍了Oracle:如何查找该月的最后一个星期五的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法,我们可以用sql或pl/sql编写查询以查找当前月份的最后一个星期五的日期吗? 在此先感谢!!!
Is there any way, we can write a query in sql or pl/sql to find date of last friday of current month ? Thanks in advance !!!
推荐答案
您可以使用LAST_DAY( SYSDATE )
获取该月的最后一天.如果从中减去7天,则可以使用NEXT_DAY()
函数查找该月的最后一个星期五:
You can use LAST_DAY( SYSDATE )
to get the last day of the month. If you subtract 7 days from that then you can use the NEXT_DAY()
function to find the last Friday of the month:
SELECT NEXT_DAY(
LAST_DAY( SYSDATE ) - INTERVAL '7' DAY,
'FRIDAY'
)
FROM DUAL;
如果要将日期截断到当天的午夜,请在TRUNC()
中将其包装.
Wrap it in TRUNC()
if you want to truncate the date to midnight of that day.
这篇关于Oracle:如何查找该月的最后一个星期五的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文