Solved

Run If Date compare (ignore time) not working

  • 15 September 2022
  • 4 replies
  • 17 views

Good Morning!



I have a site workflow where I'm trying to compare two dates (both workflow variables). Here is variable 1





 



from logging, this evaluates to 10/25/2021 12:00AM.



 



My second date is from a list query:





 



this is also logging at 10/15/2021.



 



Here is my Run If





 and for sanity i'm doing a dateDiff on the side





 



The result is 0. So these dates are definitely the same. Why isn't the Run if tripping?   I guess I could do a Run If the dateDiff is 0, but I was previously told by nintex not to have numerous dateDiffs execute on a workflow run because it will cause problems. This set of logic is within a loop that will definitely execute numerous times. What should I do?

icon

Best answer by bamaeric 15 September 2022, 16:59

View original

4 replies

Userlevel 5
Badge +13

Hi @nderiley 



 



Your logic seems solid.



 



To temporarily assist with code debugging



- Replace the RUN-IF with a Conditional Branch



- Display both values before the Conditional Branch



- Display which Branch was taken





 



If the NO Branch is taken, there must be something wrong with one of the values.



Most common is incorrect assignment or assign to a different variable



Perhaps its not a DateType type value - Value is Text-type?



 



 

Userlevel 5
Badge +10

Try converting the first date that includes the time to a compatible format the FormatDate inline function in a Set Variable actions.  Follow these steps:



 





  1. Add a Set Variable action right after the action where you set the 30days variable.


  2. Configure the Set Variable action



    1. Create a new Text variable (ex. txt30Days) and select it in the Set dropdown.


    2. Keep "Equals Value".


    3. Click on the Insert Reference value to the right.


    4. Go to the Inline Functions tab.


    5. Select the FormatDate function to start configuring the "Dynamic text to insert.


    6. Configure the FormatDate function as: fn-FormatDate(dt30days,"M/d/yyyy")


    7. This will format your date as 10/15/2021.






  3. You might have to create another Text variable and format it with these same steps for the second date to use in your date comparison action.




This works, but the format I have to use is MM/dd/yyyy
Userlevel 5
Badge +10

Great! Here's a good blog post about formatting date/time strings: https://community.nintex.com/t5/Community-blogs/Date-and-Time-Format-Strings-Quick-Reference-Guide/ba-p/81050 

Reply