本月的当前周号 [英] Current week number for current month
本文介绍了本月的当前周号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下查询获取当前星期
I used following query to get current week
选择摘录(current_timestamp中的星期)
34
很好。
但是我如何获取当前月份的当前周数。
But how do i get the current week number of the current month.
推荐答案
您可以通过以下方式找到本周的第一天:
You can find the first day of this week with:
trunc('week', current_date)
第一个的第一天本月的一周,其中:
And the first day of the first week of this month with:
trunc('week', date_trunc('month', current_date))
将两者相减得出月内周数:
Subtract the two to find the in-month weeknumber:
extract('day' from date_trunc('week', current_date) -
date_trunc('week', date_trunc('month', current_date))) / 7 + 1
这篇关于本月的当前周号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文