Hi @tgut03 ,
If it is not compulsory to use python only to generate this. You can try this with Vbscript.The correct updated VBscript is provided below. You Can use Run Vbscript action to get the recent Saturday Date.
' Function to get the most recent Saturday date in the current month
Function GetRecentSaturday()
Dim currentDate, currentMonth, currentYear
Dim dayOfWeek, recentSaturday
' Get the current date without time
currentDate = Date
currentMonth = Month(currentDate)
currentYear = Year(currentDate)
' Initialize recentSaturday with the current date
recentSaturday = currentDate
' Find the most recent Saturday
Do While Weekday(recentSaturday) <> vbSaturday
recentSaturday = DateAdd("d", -1, recentSaturday)
Loop
' If the recent Saturday is in the previous month, find the last Saturday of the current month
If Month(recentSaturday) <> currentMonth Then
recentSaturday = DateSerial(currentYear, currentMonth + 1, 0)
Do While Weekday(recentSaturday) <> vbSaturday
recentSaturday = DateAdd("d", -1, recentSaturday)
Loop
End If
' Return the recent Saturday
GetRecentSaturday = recentSaturday
End Function
' Call the function and display the result
Dim recentSaturday
recentSaturday = GetRecentSaturday()
WScript.Echo "The most recent Saturday date in this month is: " & recentSaturday
(Note:- if you got your solution you can mark as solution and gives kudos)
Thanks & Regards
Vishnu Reddy