Today is 5.27.2010 - this means that it is day 147 of this year.
5.27.2010
How can I calculate that today is 147 based on the current date?
There is a DateTime property called: DayOfYear
DateTime
Console.WriteLine(DateTime.Now.DayOfYear);
Or for any date:
var d = new DateTime(2010, 5, 30); Console.WriteLine(d.DayOfYear);
Actually, this is pretty easy:
int dayOfYear = DateTime.Today.DayOfYear;
The C # DateTime class has a DayOfYear() method that you could use.
DayOfYear()
Has anyone mentioned the DateTime.DayOfYear property?
DateTime.DayOfYear
DateTime dt = new DateTime(2001, 12, 14); dynamic dayofyear = dt.DayOfYear; dynamic datofweek = dt.DayOfWeek;
Source: https://habr.com/ru/post/1311112/More articles:ImportError: no module named QtWebKit - pythonIs the "data transfer type" the same as the "data transfer object"? - c # -3.0Oracle DBMS_PROFILER shows only Anonymous in result tables - oracleZend Framework - controller module extension - moduleA simple example of a custom .net installer using the path to an installed application - installerIE8 Print only 1 web page - internet-explorerClear Keychain for iPhone - iphoneDetecting if a file is binary or plain text? - fileDifference between exceptions and errors? - phpWhat is a good practical example of using the dynamic Runtime language in .NET 4.0? - .net-4.0All Articles