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 ((int)endD.DayOfWeek == 6) calcBusinessDays –-; if ((int)startD.DayOfWeek == 0) calcBusinessDays –-; return calcBusinessDays; } Add work […]