Count number of Mondays in a given date range

后端 未结 15 1307
南旧
南旧 2020-11-28 09:35

Given a date range, I need to know how many Mondays (or Tuesdays, Wednesdays, etc) are in that range.

I am currently working in C#.

15条回答
  •  没有蜡笔的小新
    2020-11-28 10:08

    Add the smallest possible number to make the first day a Monday. Subtract the smallest possible number to make the last day a Monday. Calculate the difference in days and divide by 7.

提交回复
热议问题