Skip to main content
Nintex Community Menu Bar
Solved

Comparing two dates

  • July 4, 2017
  • 12 replies
  • 467 views

Forum|alt.badge.img+7

Hi,

 

I created the following workflow. I am trying to compare today's date with 25 (of the month) If today's date = 25th then run the emailer. I am stuck at defining variable. I was able to define 'DDate = 25'. However, I could not assign 'ToDate' as today's date.

 

Also in run if, I understand I cannot compare 'Todate' (07.04.2017) with 'DDate' (25). How do I extract the day portion of today's date only?

 

Thanks! 

Kindly let me know what I am doing wrong.

 

 

Best answer by jackgelo

Hi,

In Nintex for O365 there are no runtime functions, that's why you still see the fn-FormatDate(...)..

a possible workaround is the following:

- create a date/time variable and set it as current date inside the workflow

- create a text variable set as in the picture:

- do a regular expression on the text variable in order to replace everything before the first / and save results in the same variable

- do a regular expression on the text variable in order to replace everything after the first / and save results in the same variable

Maybe there is a quicker way to do a regExp that select everything outside the first two / in just one action, but this also do the work..

Two regular expression are needed to extract day part of a date in format MM/DD/YYYY, if your date is instead in format DD/MM/YYYY, then first regex is not needed.

Giacomo

12 replies

Forum|alt.badge.img+16
  • 898 replies
  • July 4, 2017

You could add a column to your list and calculate the DATE() of your date. 

Suppose you column name is birthDate and a value is 25/12/2000, and you create a column named birthDate_DATE ( calculated DATE(birthDate)) , the value will be 25.

You could use birthDate_DATE in your workflow.


Forum|alt.badge.img+7
  • Author
  • 35 replies
  • July 5, 2017

Hi,

Thank you for your suggestion. I've created a column called 'Day_Only' in my list and that displays the day of the month.

The workflow is running and stuck there as status 'started'. The error I am getting when I click on workflow status is this 'The field 'Day_x0020_Only' of type 'Calculated' cannot be used in the query filter expression '

The Day_Only calculates to 5 on the list-view and there is only 1 item on list.

PS: I created a new column called 'Next Day' as a static value holding column. Assigned it number 5. Then pulled this into workflow and it worked. The workflow seems to have issues with 'calculated' fields (unless I am doing something wrong).

Is there any other ways to calculate the 'day' portion of the current date within the workflow? This would be helpful for me in designing future workflows which has to  be triggered if the current date = due date (of a list item)/etc.


Forum|alt.badge.img+12
  • Apprentice
  • 293 replies
  • July 6, 2017

Hi Shanan,

Follow the below steps:

1. Create a date type variable and set "Blank" for default date.

2. Create a single line text variable.

3. Create a Number type variable.

4. Insert workflow action, Set Variable , assign date variable with "use date when action is executed"

5. Insert another workflow action, Set Variable, assign text variable with "fn-FormatDate(datevariable, "dd")

6. Insert "Convert Value" workflow action, and convert "text variable" to "number variable"

7. Insert Run If action, check if "number variable is "x number"

8. Then send email.


Forum|alt.badge.img+7
  • Author
  • 35 replies
  • July 7, 2017

Thanks!

I am getting an error 'Input string was not in a correct format'. Below are some screenshots from inside the actions

Any help is much appreciated!

Converting text to number below


Forum|alt.badge.img+12
  • Apprentice
  • 293 replies
  • July 7, 2017

Hi,

Better keep a log and display the value in DataType and TextType variables before the each wrokflow actions, and see if the variables have correct values.


Forum|alt.badge.img+7
  • Author
  • 35 replies
  • July 7, 2017

Thanks. I did that and here is the result before going into 'convert value' box (and after defining values)

TextValue (should this show the formula considering it is logging after the formula?)

fn-FormatDate(7/7/2017 3:12:26 PM,"dd")

DateValue

7/7/2017 3:12:26 PM


Forum|alt.badge.img+12
  • Apprentice
  • 293 replies
  • July 7, 2017

So, what is the output value for TextVariable when you assign it with fn-FormatDate(7/7/2017 3:12:26 PM,"dd")?

It supposed to return "7" (in text variable).

Then convert this "7" (text variable) to number.

It should work.


Forum|alt.badge.img+7
  • Author
  • 35 replies
  • July 7, 2017

Hi,

The first log-history, I put in '{Variable:TextType}' as description. Second one same thing - I got the following results respectively. In one of the above screen caps I have shown the formula as written.

Could this be caused by the time attached to the date?


Forum|alt.badge.img+12
  • Apprentice
  • 293 replies
  • July 7, 2017

No, it can not be an issue, I see the time portion appended to date in my workflow too.

I am using On-Premises Nintex workflows, and yours is Office 365 Nintex. There should not be any problem with date functions as per my knowledge.

Can you give a try by hard coding the date value in FormatDate() function? like, fn-FormatDate("7/7/2017","dd")

and replace double quotes with single quotes if the above not worked. 


Forum|alt.badge.img+7
  • Author
  • 35 replies
  • July 7, 2017

Same issue

I've attached my workflow for your reference. Thanks for the help up to this point!


Forum|alt.badge.img+11
  • Scout
  • 444 replies
  • Answer
  • July 10, 2017

Hi,

In Nintex for O365 there are no runtime functions, that's why you still see the fn-FormatDate(...)..

a possible workaround is the following:

- create a date/time variable and set it as current date inside the workflow

- create a text variable set as in the picture:

- do a regular expression on the text variable in order to replace everything before the first / and save results in the same variable

- do a regular expression on the text variable in order to replace everything after the first / and save results in the same variable

Maybe there is a quicker way to do a regExp that select everything outside the first two / in just one action, but this also do the work..

Two regular expression are needed to extract day part of a date in format MM/DD/YYYY, if your date is instead in format DD/MM/YYYY, then first regex is not needed.

Giacomo


Forum|alt.badge.img+7
  • Author
  • 35 replies
  • July 10, 2017

Thanks