Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
how can i check that the current financial year changed ?

What I have tried:

I have tried to write like this
var dat=DateTime.Now().day
var mon=DateTime.Now().month
if(dat==1 && mon==1)
{

// Some Code
}
Posted
Updated 11-Mar-17 22:10pm

An easier property to use:
C#
if (DateTime.Now.DayOfYear == 1) {
    // Some code
}
 
Share this answer
 
Quote:
How to check year is changed from date

Assuming your code is corrected, you do not test if the year have changed or not, you test if first day of year.
That test fail if launch more than once that day, and it also fail if not launch that day for any reason.
C#
var lasttest;
// reload lasttest from save
var today = DateTime.Now;
if (lasttest.year < today.year)
{
	// Some Code
}
lasttest = today;
// save lasttest for later use

This code success in any case.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900