Alec Pojidaev's InfoPath Blog
Stuff published for no reason (cool codeless infopath solutions mostly)

Posts Tagged ‘C#

Work (business) days calculations with C#

October 29, 2009

If you think it’s a decent solution vote for it! :)   Work days between 2 dates: public static double GetBusinessDays(DateTime startD, DateTime endD) { double calcBusinessDays = 1 + ((endD-startD).TotalDays * 5 – (startD.DayOfWeek-endD.DayOfWeek) * 2) / 7; if (endD.DayOfWeek == DayOfWeek.Saturday) calcBusinessDays –; if (startD.DayOfWeek == DayOfWeek.Sunday) calcBusinessDays –; return calcBusinessDays; }   Note […]