本文介绍了计算财务年度的日期,从日期算起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做一些关于财政年度的计算。财政年度从4月1日开始。

I want to do calculations about financial year. Financial Year starting at April 1.

因此季度从4月开始。 这里的并发症是明年第四季度。 年份发生变化。

Hence quarter begins from April. Here complication is 4th quarter is next year.  The year changes.

如何在计算过程中牢记这一点?

How to keep this in mind during calculations?

如何确保我没有错误的当前年份第四季度?

How to make sure I have not mistaken current year of 4th quarter?

public static int GetQuarter(DateTime date)
        {
            if (date.Month >= 4 && date.Month <= 6)
                return 1;
            else if (date.Month >= 7 && date.Month <= 9)
                return 2;
            else if (date.Month >= 10 && date.Month <= 12)
                return 3;
            else
                return 4;
        }

问候。

如果他们提供帮助,请记得将回复标记为答案,如果他们没有提供任何帮助,请记下他们取消标记,或者您可以投票给有用的帖子

Please remember to mark the replies as answers if they help and unmark them if they provide no help , or you may vote-up a helpful post

推荐答案

public static int GetQuarter(DateTime date, int year)
        {
            if (date.Month >= 4 && date.Month <= 6 && date.Year == year)
                return 1;
            else if (date.Month >= 7 && date.Month <= 9 && date.Year == year)
                return 2;
            else if (date.Month >= 10 && date.Month <= 12 && date.Year == year)
                return 3;
            else if (date.Month >= 1 && date.Month <= 3 && date.Year - 1 == year)
                return 4;
            else
                // however you want to deal with an error...
        }


这篇关于计算财务年度的日期,从日期算起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 02:12