我有一个财政年度的月末价值2。
如何根据该值计算财政年度的DateTime startDate和DateTime endDate?
发布于 2020-12-09 13:57:43
如果您当前的日期是2021年1月14日,那么印度的财政年度是2020年4月1日至2021年3月31日
使用以下代码来获得完美的输出。
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);
}https://stackoverflow.com/questions/5049562
复制相似问题