Solved

Comparing two dates


Badge +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.

 

 

icon

Best answer by jackgelo 10 July 2017, 10:47

View original

12 replies

Userlevel 6
Badge +16

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.

Badge +7

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.

Userlevel 3
Badge +12

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.

Badge +7

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

Userlevel 3
Badge +12

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.

Badge +7

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

Userlevel 3
Badge +12

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.

Badge +7

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?

Userlevel 3
Badge +12

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. 

Badge +7

Same issue

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

Userlevel 4
Badge +11

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

Badge +7

Thanks

Reply