How to extract the number of remaining business days in bot running month

Hi Team, I want to count the number of remaining business days from the date bot is running. Lets say if bot is running on 26th august(Monday), then the response should be 4 business days remaining in august (till Friday- 30th Aug)

Hi @srivastavadeeksha123

Can you try the below

Enumerable.Range(1, (New DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)) - DateTime.Now).Days) _
    .Select(Function(d) DateTime.Now.AddDays(d)) _
    .Count(Function(d) d.DayOfWeek <> System.DayOfWeek.Saturday AndAlso d.DayOfWeek <> System.DayOfWeek.Sunday)

Regards,

Hi @lrtetala
Its working… Thank you so much!!

1 Like

If you want more detail like know Day, Hour and minutes remaining.

You can try this one.

DayRemainings = LastDayOnTheMonth.Subtract(todayDate)

For Message Box:

DayRemainings.Days.ToString() + " Days " + DayRemainings.Hours.ToString() + " hour " + DayRemainings.Minutes.ToString() + " Minutes "

Thank You
Best,
Wahyu M Rizqi

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.