cancel
Showing results for 
Search instead for 
Did you mean: 

Previous Date Logic

sandeshtope
Level 5

I need to write two dates into a text field in the format dd.MM.yyyy. The start date should be the nearest previous 15th, and the end date should be today's date. Any tips on how to do this in Blue Prism? Your advice would be a big help! Thanks!



------------------------------
Sandy P
RPA Developer
------------------------------
1 BEST ANSWER

Helpful Answers

Hi @Sandy P -  What if today's date is 01-November - do you still want 15th of October ?

ToNumber(Left(Today(),2))>15  - Where you can decide to check the previous nearest 15th. i.e. this gives you False decision - 

If False - Calculation Stage - 17678.png

If True : 

17679.png

------------------------------
Regards,

Mukesh Kumar - Senior Automation Developer

NHS, England, United Kingdom, GB
------------------------------

Regards,

Mukesh Kumar

View answer in original post

12 REPLIES 12

Hi Sandy,

You can try something like below.

Start Date:

17653.png

Today :

17654.png



------------------------------
Athiban Mahamathi - https://www.linkedin.com/in/athiban-mahamathi-544a008b/
Technical Consultant,
SimplifyNext,
Singapore
------------------------------

if today's date is, for instance, 31st October, I want the start date to be the nearest previous 15th, which means it should be 15th October. How can I handle this situation ?



------------------------------
Sandy P
------------------------------

Hi Sandy,

You can use a decision stage to find if the today's date is crossed current month 15th. If yes, then you can get the current month 15th date else you can get the previous month 15th date.



------------------------------
Athiban Mahamathi - https://www.linkedin.com/in/athiban-mahamathi-544a008b/
Technical Consultant,
SimplifyNext,
Singapore
------------------------------

Hi Atibhan ,

What to provide in decision stage ?



------------------------------
Sandy P
------------------------------

I tried , but it did not worked !

How can we compare date ? 



------------------------------
Sandy P
------------------------------

Hi @Sandy P -  What if today's date is 01-November - do you still want 15th of October ?

ToNumber(Left(Today(),2))>15  - Where you can decide to check the previous nearest 15th. i.e. this gives you False decision - 

If False - Calculation Stage - 17678.png

If True : 

17679.png

------------------------------
Regards,

Mukesh Kumar - Senior Automation Developer

NHS, England, United Kingdom, GB
------------------------------

Regards,

Mukesh Kumar

Hey Mukesh

It worked ! Thanks a lot !!! 



------------------------------
Sandy P
------------------------------

Great work team 👏 Congrats @Mukesh Kumar on the best answer!



------------------------------
💙 Michael
(I'm part of the SS&C Blue Prism Community Team)
------------------------------

Sorry, I just have to point out that the answer @Mukesh Kumar gave will be incorrect at least 12 times during the year. For example; the date "11/11/2023" will give you  "15/15/2023" with the Replace function, which will cause an error in the ToDate function.

For any regional date formats, you can use the following for days under 16:

AddMonths(MakeDate(15, FormatDate(Today(), "MM"), FormatDate(Today(), "yyyy")),-1)

Else

MakeDate(15, FormatDate(Today(), "MM"), FormatDate(Today(), "yyyy"))

Addendum:
For any regional date formats, you can use the following for the decision:

ToNumber(FormatDate(Today(), "dd")) < 16



------------------------------
Micheal Charron
Senior Manager
RBC
America/Toronto
------------------------------

Micheal Charron
RBC
Toronto, Ontario
Canada