简体   繁体   English

静态会计年度的自定义周

[英]Custom week for static fiscal year

I'm trying to create logic for custom weeks in a fiscal year that always starts on Jan 1st, and ends on Dec 31st. 我试图在一个财政年度创建自定义周的逻辑,该财政年度总是从1月1日开始,到12月31日结束。 I was able to get the correct week numbers for each month, but can't customize the weeks correctly for the year. 我能够获得每个月的正确周数,但无法正确定制一年中的周数。 For instance, the data still shows week 53 for the first two days of January 2016. In short, Week 1 should start on 1/1/yyyy and week 52 or 53 (in some cases) end on 12/31/yyyy. 例如,数据仍显示2016年1月前两天的第53周。简而言之,第1周应从1/1 / yyyy开始,第52周或53(有些情况下)以12/31 / yyyy结束。

Any suggestions will be greatly appreciated. 任何建议将不胜感激。 Thank you. 谢谢。

L 大号

MYSQL MYSQL

SELECT CEILING(DAYOFYEAR('your date') / 7)

POSTGRES POSTGRES

SELECT CEILING(EXTRACT('DOY' FROM DATE 'your date') / 7)

ORACLE ORACLE

SELECT CEIL(TO_CHAR(SYSDATE, 'DDD') / 7)

试试这个你可以将@YourDate替换为你想要检查的日期

SELECT DATEPART( wk, @YourDate)

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

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