Skip to content

Instantly share code, notes, and snippets.

@UweKeim
Last active November 14, 2017 06:53
Show Gist options
  • Save UweKeim/6f4e58825bd99727436c6d6b188b72f6 to your computer and use it in GitHub Desktop.
Save UweKeim/6f4e58825bd99727436c6d6b188b72f6 to your computer and use it in GitHub Desktop.
Calculate DayOfCentury for C# DateTime, similar to DayOfYear
/// <description>
/// Calculates the total number of days passed sind first of January 2000
/// until a given Date.
/// </description>
public static long DayOfCentury(DateTime dt)
{
var span = dt.Date - new DateTime(2000, 1, 1);
return (long)span.TotalDays;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment