If you are asking dynamically based on Input Date. Here is one approach:
day = "13-12-2024"
dayDateTime = DateTime.ParseExact(day, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture)
lastDay = New DateTime(dayDateTime.Year, dayDateTime.Month, 1).AddDays(-1)
lastDayOfMonth = If( lastDay.DayOfWeek = System.DayOfWeek.Saturday OrElse lastDay.DayOfWeek = System.DayOfWeek.Sunday, lastDay.AddDays(-1).ToString("dd-MM-yyyy"), lastDay.ToString("dd-MM-yyyy"))
There is no need of 4 different variables. You can manage with just 2. But i have made 4 for readability:
THE OUTPUT:
If this solves your issue, Do mark it as a solution
Happy Automation ![]()

