cancel
Showing results for 
Search instead for 
Did you mean: 

A Simple Blue Prism Code for Calculating Last Sunday and Saturday Dates

uzershaikh1
Level 3

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

26582.png

Input and Output Variables all in Date Format

26583.png

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)
Else 
  LastSunday = today.AddDays(-daysUntilSunday - 7)
End If 
Finally 
End Try 
Try daysUntilSaturday = (today.DayOfWeek - DayOfWeek.Saturday + 7) Mod 7
   If daysUntilSaturday = 0 Then
   LastSaturday = today.AddDays(-7)
Else 
LastSaturday = today.AddDays(-daysUntilSaturday) 
End If 
Finally 
End 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
------------------------------

Uzer Shaikh - Developer Consultant – Automation Developer Wonder Botz Pvt Ltd. Ahmedabad, India
1 REPLY 1

Hello,

Thanks for shared (:

Regards,



------------------------------
Leonardo Soares
RPA Developer Tech Leader
Bridge Consulting
América/Brazil
------------------------------
Leonardo Soares RPA Developer América/Brazil