Skip to main content
edited tags
Link
200_success
  • 144.1k
  • 22
  • 188
  • 473
Tweeted twitter.com/StackCodeReview/status/717178168554168320
deleted 79 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

C# Is this Getting the best way to get what business day of the month it currently is?

I'm working on figuring out what the current 'business' day of the month it is. So sayFor instance, if it's the 20th, but there are 3 weekends, it would be the 14th business day of the month. The following is what I have.

Is there a better way of doing this?

        var first = DateTime.Today.FirstDayOfMonth();
        var businessDayOfMonth = 0;
        for (var i = first; i <= DateTime.Today; i = i.AddDays(1))
        {
            if (i.DayOfWeek != DayOfWeek.Saturday && i.DayOfWeek != DayOfWeek.Sunday) 
                businessDayOfMonth++;
        }

Is there a better way of doing this?

C# Is this the best way to get what business day of the month it currently is?

I'm working on figuring out what the current 'business' day of the month it is. So say if it's the 20th, but there are 3 weekends, it would be the 14th business day of the month. The following is what I have.

        var first = DateTime.Today.FirstDayOfMonth();
        var businessDayOfMonth = 0;
        for (var i = first; i <= DateTime.Today; i = i.AddDays(1))
        {
            if (i.DayOfWeek != DayOfWeek.Saturday && i.DayOfWeek != DayOfWeek.Sunday) 
                businessDayOfMonth++;
        }

Is there a better way of doing this?

Getting the business day of the month

I'm working on figuring out what the current 'business' day of the month it is. For instance, if it's the 20th, but there are 3 weekends, it would be the 14th business day of the month.

Is there a better way of doing this?

var first = DateTime.Today.FirstDayOfMonth();
var businessDayOfMonth = 0;
for (var i = first; i <= DateTime.Today; i = i.AddDays(1))
{
    if (i.DayOfWeek != DayOfWeek.Saturday && i.DayOfWeek != DayOfWeek.Sunday) 
        businessDayOfMonth++;
}
Source Link

C# Is this the best way to get what business day of the month it currently is?

I'm working on figuring out what the current 'business' day of the month it is. So say if it's the 20th, but there are 3 weekends, it would be the 14th business day of the month. The following is what I have.

        var first = DateTime.Today.FirstDayOfMonth();
        var businessDayOfMonth = 0;
        for (var i = first; i <= DateTime.Today; i = i.AddDays(1))
        {
            if (i.DayOfWeek != DayOfWeek.Saturday && i.DayOfWeek != DayOfWeek.Sunday) 
                businessDayOfMonth++;
        }

Is there a better way of doing this?