C# - Duration between two DateTimes in minutes

后端 未结 9 1062
醉话见心
醉话见心 2020-12-16 11:58

I need to determine duration between two DateTimes in minutes.

However, there is a slight twist:

  • exclude weekends
  • only count minutes which a
9条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 12:02

    I won't write any code, but having a DateTime you can tell the Day of the week, thus you know how many weekends are in your range, so you can tell how many minutes are in a weekend.

    So it wouldn't be so hard... of course there must be an optimal one line solution... but i think you can get around with this one.

    I forgot to mention that you also know the minutes btween 7:00 pm and 7:00 am so all you have to do is substract the right amount of minutes to the time difference you get.

提交回复
热议问题