C# get current fiscal year stop and end dates

The following two functions can be used to determine the start and stop dates of the current fiscal year. They assume a standard FY of 10/1 - 9/30. The same logic applies if you want to modify them with different start dates. You will just need to use whatever DateTime values you want instead of the current.

Get the start date

// get the current month and year
int month = DateTime.Now.Month;
int year = DateTime.Now.Year;

// if month is october or later, the FY started 10-1 of this year
// else it started 10-1 of last year
return month > 9 ? new DateTime( year, 10, 1 ) : new DateTime( year - 1, 10, 1 );



Get the stop date

// get the current month and year
int month = DateTime.Now.Month;
int year = DateTime.Now.Year;

// if month is october or later, the FY ends 9/30 next year
// else it ends 9-30 of this year
return month > 9 ? new DateTime( year + 1, 9, 30 ) : new DateTime( year, 9, 30 );

Comments

Popular posts from this blog

String.Replace vs Regex.Replace

C# Producer Consumer using Rabbit MQ

C# Form Application in Kiosk Mode/Fullscreen