Today is 5.27.2010 - this means it is day 147 of this year.
How do I calculate that today is 147 based on the current date?
Today is 5.27.2010 - this means it is day 147 of this year.
How do I calculate that today is 147 based on the current date?
There's a DateTime
property named just that: DayOfYear
Console.WriteLine(DateTime.Now.DayOfYear);
Or for any date:
var d = new DateTime(2010, 5, 30);
Console.WriteLine(d.DayOfYear);
Actually, it's pretty easy:
int dayOfYear = DateTime.Today.DayOfYear;
C#'s DateTime class has a method called DayOfYear() that you could use.
Has anyone mentioned the DateTime.DayOfYear
property? lol =P
DateTime dt = new DateTime(2001, 12, 14);
dynamic dayofyear = dt.DayOfYear;
dynamic datofweek = dt.DayOfWeek;