我如何获得财务年度日期范围 [英] How do I get financial year date range

查看:114
本文介绍了我如何获得财务年度日期范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有两个日期startDate和EndDate。根据这个日期范围,我需要查找相同日期范围的财务年度开始日期和结束日期。



我需要一个sql查询。



i尝试如下:



Hi,

I have tow dates startDate and EndDate. Depending on this date range I need to find financial year start date and end date for the same date range.

I need an sql query for the same.

i tried like:

SET @StartDate = DATEADD(dd,0, DATEDIFF(dd,0, DATEADD
( mm, -(((12 + DATEPART(m, GETDATE())) - 4)%12), GETDATE() )
    - datePart(d,DATEADD( mm, -(((12 + DATEPART(m, GETDATE())) - 4)%12),GETDATE() ))+1 ) )
set @EndDate=GETDATE()





但我猜它会给我当前的财政年度..

请帮帮我。



but i guess it will give me current financial year..
Please help me out.

推荐答案





根据解决方案1,财政不同国家的年份不同。在这里,我可以给你一些例子,但你仍然需要根据你的要求做最后的工作。





这里GETDATE()5月替换您的日期



Hi,

As per solution 1, fiscal year is different for different countries. Here i can give you little example but still you have to do final work out as per your requirement.


Here GETDATE() May Replace "Your Date"

SELECT QM_FIN_YEAR =
        CASE
            WHEN Month(GETDATE()) BETWEEN 4 AND 12
                THEN CONVERT(VARCHAR(4),YEAR(GETDATE())) + '-' + CONVERT(VARCHAR(4),YEAR(GETDATE()) + 1)
            WHEN Month(GETDATE()) BETWEEN 1 AND 3
                THEN CONVERT(VARCHAR(4),YEAR(GETDATE()) - 1) + '-' + CONVERT(VARCHAR(4),YEAR(GETDATE()) )
End ORDER by 1 DESC







希望这会对你有帮助。




Hope this will help you.


你必须自己编写代码:没有这种事作为普遍的财政年度,每个国家都有不同的财政年度: http://en.wikipedia.org/wiki/Fiscal_year [ ^ ]



所以你必须弄清楚你想要的国家,并自己移动到适当的范围。
You will have to code this for yourself: there is no such thing as a "universal" financial year, and each country has a different one: http://en.wikipedia.org/wiki/Fiscal_year[^]

So you will have to work out what country you want, and move to the appropriate range yourself.


这篇关于我如何获得财务年度日期范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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