Home
Manage Your Code
Snippet: 100 Year Day (C#)
Title: 100 Year Day Language: C#
Description: Takes a DateTime value and calculates the number of days since 12/31/1899. Used mostly when accessing AS400 applications that store dates as number of days. Views: 453
Author: Don Miller Date Added: 6/1/2007
Copy Code  
1private int hundredYearDay(DateTime day)
2{
3	DateTime startYear = new DateTime(1899, 12, 31);
4        TimeSpan daySpan = day.Subtract(startYear);
5        string noDays = daySpan.TotalDays.ToString();
6        string[] dayParts = noDays.Split(new char[] { '.' });
7        int days = Convert.ToInt32(dayParts[0]);
8        return days;
9}