How to find current date -8 working days


I need to find the result of current date - 8 working days(excluding the weekends).
i.e., the weekends should not be added while calculating.
Result should be date format.

Can anyone help me with the solution?

Hi @rnahasnahasuddin

Try this

Enumerable.Range(1, 20).
    Select(Function(n) DateTime.Now.AddDays(-n)).
    Where(Function(d) d.DayOfWeek <> DayOfWeek.Saturday And d.DayOfWeek <> DayOfWeek.Sunday).



If you want in particular date format then try below


Thanks for the quick response.

Can you please explain what does Enumerable.Range(1, 20), this means?


It generates a sequence of the last 20 days (ensuring we have enough days to count back 8 working days).

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