// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { class MainClass { public static int WorkDays(DateTime t1, DateTime t2) { int res = 0; DateTime t = t1; while(t <= t2) { if(DayOfWeek.Monday <= t.DayOfWeek && t.DayOfWeek <= DayOfWeek.Friday) { res++; } t = t.AddDays(1); } return res; } public static void Main(string[] args) { Console.WriteLine(WorkDays(new DateTime(2005, 11, 10), new DateTime(2005, 11, 14))); } } }