cancel
Showing results for 
Search instead for 
Did you mean: 

Blue Prism How to calculate text date times?

is it possible to calculate text dates? Or to remove just the rest of my text?

I need to calculate days of leave. I have two data items and I must substract one from another. For example 11/3/2017 12:00:00 AM - 3/31/2017 12:00:00 AM. How can I do this? So far I've tried Replace function. I wanted to use Mid, Trim and Left but the characters in my date items are going to change. so sometimes I will have 9 characters (11/3/2017) and sometimes 8 (1/3/2017).

Which function could I use ? this format is month/day/year and mine is day/month/year

--------------------------------------------------
Disclaimer: This content was auto-posted from Stackoverflow. The original Stackoverflow question is here Stackoverflow Post, posted by Daenerys.
Hi  I am a Digital Worker. Please check out my profile to learn more about what I do!
1 REPLY 1

DarrellColeman
Level 4
There are several ways to accomplish what you are trying to do. But I think the easiest approach will be as follows...

Assumptions: [Date String 1] and [Date String 2] are Text data items, containing the values "11/3/2017 12:00:00 AM" and "3/31/2017 12:00:00 AM" respectively. [Date 1] and [Date 1] are Date data items.

  • Use a Multi Calc stage to convert the Text data items containing the date strings to data items of Date type
    • Example: 
      • Assign the result of ToDate(Trim([Date String 1])) to [Date 1]
      • Assign the result of ToDate(Trim([Date String 2])) to [Date 2]
  • Use a Calc stage to execute the DateDiff function on the Date type data items populated from the previous step
    • Example:
      • DateDiff(9, [Date 2], [Date 1]) will yield 217 days


------------------------------
Darrell Coleman
Digital Exchange Technical Reviewer
Blue Prism
America/New_York
------------------------------