cancel
Showing results for 
Search instead for 
Did you mean: 

#BPTechTips - Date Intervals

AndrewPascal
Level 5
If - like me - you're a human, you probably have trouble dealing with those "magic numbers" in the DateDiff() and DateAdd() functions. You know - DateDiff(6, [Start Date Time], Now()) counts the number of elapsed... somethings. But what? Does 6 mean we're counting hours? Or minutes? Or even months?

To make this stuff easier to read - and easier to write as well - I create a one-row collection called Date Intervals, and make it globally visible
23978.png
Initialise all the fields to the secret magic numbers from the Blue Prism help file:
23979.png
Now I can refer to [Date Intervals.Minute] instead of "6", and it's easy to understand what the calculation's doing:
23980.png
Just copy the one-row collection to any object or process to enjoy never having to work out those pesky Date Intervals again 🙂

Hope you find this helpful.

------------------------------
Andrew Pascal
------------------------------
6 REPLIES 6

Thanks for sharing @AndrewPascal

------------------------------
Manpreet Kaur
Manager
Deloitte
------------------------------

JeremyRTDean
Level 5

Love this, great suggestion and well illustrated!



------------------------------
Jeremy Dean
------------------------------

Why don't you use simply :

ToMinutes([DateTime 2] - [DateTime 1])



------------------------------
Johan Michiels
------------------------------

I think the point was that many people don't remember the numeric representatives of the time periods (Day is 9, Month is 5 etc.) and they're not very easy to find, especially when you're trying to work out something quickly.  The numbers are also an easy way to hide bugs in your code, as I found yesterday when I realised I'd used a 4 rather than a 5 in a DateDiff calculation...



------------------------------
Jeremy Dean
------------------------------

I agree Jeremy I just wanted to offer an easier way to do it knowing that Bleuprism warns that DateDiff is deprecated ! 

Time to get rid of it 😉



------------------------------
Johan Michiels
------------------------------

Interesting!  I needed to identify transactions where the different between start and end dates was no more than 3 months so I did this:

(DateDiff([Date Intervals.Month], [RFC Start Date], [RFC End Date]))<=3

I could have used ToDays and 90 as you suggest.



------------------------------
Jeremy Dean
------------------------------