首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何根据财务年度的月末数值计算财务年度的起止日期?

如何根据财务年度的月末数值计算财务年度的起止日期?
EN

Stack Overflow用户
提问于 2011-02-19 15:42:18
回答 5查看 13.5K关注 0票数 1

我有一个财政年度的月末价值2

如何根据该值计算财政年度的DateTime startDateDateTime endDate

EN

Stack Overflow用户

发布于 2020-12-09 13:57:43

如果您当前的日期是2021年1月14日,那么印度的财政年度是2020年4月1日至2021年3月31日

使用以下代码来获得完美的输出。

代码语言:javascript
运行
复制
DateTime CurrentDate = DateTime.Now;
int CurrentMonth = CurrentDate.Month;

if (CurrentMonth >= 4)//4 is the first month of the financial year.
{
txtFromDate.Text = new DateTime(CurrentDate.Year, 4, 1).ToString(CS.ddMMyyyy);
txtToDate.Text = new DateTime(CurrentDate.Year + 1, 4, 1).AddDays(-1).ToString(CS.ddMMyyyy);
}
else
{
txtFromDate.Text = new DateTime(CurrentDate.Year - 1, 4, 1).ToString(CS.ddMMyyyy);
txtToDate.Text = new DateTime(CurrentDate.Year, 4, 1).AddDays(-1).ToString(CS.ddMMyyyy);
}
票数 0
EN
查看全部 5 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5049562

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档