05-11-23 05:29 PM
I wanted to share a simple piece of Blue Prism code that can be useful if you need to calculate the dates for the last Sunday and Saturday based on the current date.
Code options as Below
Input and Output Variables all in Date Format
Code:
Dim daysUntilSunday As Integer
Dim daysUntilSaturday As Integer
Try
daysUntilSunday = (today.DayOfWeek - DayOfWeek.Sunday + 7) Mod 7
If daysUntilSunday = 0 Then
LastSunday = today.AddDays(-7)ElseLastSunday = today.AddDays(-daysUntilSunday - 7)End IfFinallyEnd TryTry daysUntilSaturday = (today.DayOfWeek - DayOfWeek.Saturday + 7) Mod 7If daysUntilSaturday = 0 ThenLastSaturday = today.AddDays(-7)ElseLastSaturday = today.AddDays(-daysUntilSaturday)End IfFinallyEnd Try
This code is quite straightforward and serves the purpose of finding the last Sunday and Saturday relative to the current date. You can integrate this code into your Blue Prism processes when such date calculations are required.
Feel free to modify and adapt this code to suit your specific needs. I hope this code proves helpful to others facing similar challenges. If you have any questions or need further assistance, please don't hesitate to ask.
Happy automating!
------------------------------
uzer shaikh
------------------------------
05-11-23 07:47 PM
Hello,
Thanks for shared (:
Regards,