cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

DateDiffDays failing in workflow

Jump to solution

I have a very simple workflow, which primarily need to calculate difference between two dates. I have two variables with the dates that I'd like to calculate against, and I'm logging their values:

 

1.png

I have "Build String" action, where I try to do the actual calculation:

 

2.png

Unfortunately, instead of returning the number of days between two dates, t_datesDiff is containing the string with the function definition and parameters:

3.png

4.png

What is the issue here and how it can be resolved?

Labels: (2)
0 Kudos
Reply
6 Replies
Automation Master
Automation Master

Re: DateDiffDays failing in workflow

Jump to solution

Hi Jerzy,

Ideally it should work. Instead of Build String, could you try Set Variable action? In the Value, add the function. Make sure t_datesDiff is an integer in this case and not a string. Hope it helps.

0 Kudos
Reply
Not applicable

Re: DateDiffDays failing in workflow

Jump to solution

Hi Kapil,

I tried what you suggested, however without success. The "Set Variable" action does not allow me to insert reference when I choose Number or Integer variable. It allows me to insert reference when I choose text variable, however the result is the same: instead of the value I have the string with the definition.

1_1.png

1_2.png

0 Kudos
Reply
Automation Master
Automation Master

Re: DateDiffDays failing in workflow

Jump to solution

Hi,

I know that my answer could look a bit stupid but sometimes I've solved similar problems in that way:

- have you tried to remove the function in the set variable action and re-enter it by selecting the function and the variables from the reference panel (don't type anything directly)?

If you need to have the days as a number variable during the workflow, you can use a Convert Value action to convert the string to a number.

Giacomo

Reply
Automation Master
Automation Master

Re: DateDiffDays failing in workflow

Jump to solution

Hi Jerzy,

I was thinking the same as Giacomo suggested. I hope you did not copy paste the function. Try deleting the action and recreating from scratch without any typing.

0 Kudos
Reply
Automation Master
Automation Master

Re: DateDiffDays failing in workflow

Jump to solution

I've noticed that depending on SharePoint regional settings (Locale field), date time functions may not work.

I've found a workaround :

  • Create two text variables to store the ISO format of both dates (one for reference date and one for today)
  • Before the "build string" action, insert a "set variable" action to get the ISO format of the reference date and configure it like the following (to display "Select return type" modal dialog, you need to click on "..." button) :

  • Add a second "Set variable" action to get the ISO format of today date (configure it like the previous one)
  • In the "Build string" action, instead of using the reference to the datetime variable in the DateDiffDays function, you can use the reference to the text variables where the ISO format of the dates are stored.

And it should work.

Hope this helps

Reply
Automation Master
Automation Master

Re: DateDiffDays failing in workflow

Jump to solution

Hi Jerzy Czopek‌, have you find what was causing the function to be not evaluated?

Could you share on the community what was the solution and mark the correct answer in this thread?

Thanks a lot!

Giacomo

0 Kudos
Reply