Decision stage not working

abhi1110

New Member
Hello,

I am using decision stage to check whether the age of a person is greater than 18. I am using this expression DateDiff(0, [Coll1.Date of Birth], Today()) > 18. Date of Birth is in date format. When I evaluate it using evaluate expression it shows the correct result for different cases. But while running my whole flow it is giving always result as True. It never fails. My data also contains the date of birth where age is less than 18. I am not able to understand what mistake I am doing. Please help me out.

Thanks in advance.
 

RDawson9

Geek
Staff member
Hi,

I see this quite often on the Robiquity Bootcamp. I think the issue is related to the collection you’re looking at.

Is Coll1 the collection you’ve input into the queue, rather than the collection used by Get Next Item to store the current case?

Regards
Rob
 

abhi1110

New Member
Hi Rob,

Thank you for helping me out. I am new to Blue Prism. I was doing the exact mistake which you pointed out. Coll1 is the collection I have input to the queue.

Thanks again for the help.

Regards
Abhi
 

RDawson9

Geek
Staff member
No problem! I remember making the exact same mistake when I was learning too :)

Good luck with your studies!
Rob
 

Cris800

New Member
Hi,

I have a similar problem with Datediff function. I'm just using the expression DateDiff(0, [12,[dateOfBirth], Today()) inside a Calculation item, in order to obtain a person's age. "DateOfBirth" is a data item wich contains the date of birth. When I evaluate it using evaluate expression, it shows the correct result (a number). But while running the flow it is giving with a different result. And is always the same number= 8096. No matter how many times i change the DateOfBirth, it is always the same result (8096). When a Validate the operation, blue prism shows this message: "Expression uses the function DateDiff which is deprecated.

What does that mean? Am i doing something wrong? Hope you can help me out. Thanks.
 

RDawson9

Geek
Staff member
Hi @Cris800

Why is there a 12 in your function? Instead of:

DateDiff(0, [12,[dateOfBirth], Today()) it should be DateDiff(0, [[dateOfBirth], Today())

Could you provide a screenshot of your process please?

Deprecated means that something is generally discouraged from use because it's usually been superseded by something else. I'll look into this further.

Rob
 

VJR

Well-Known Member
Hi Cris800,

As pointed out by RDawson9, you will not need the 12 in the function.
The first parameter of DateDiff is the interval. 0 is for the interval in years, 1 is for weeks, and so on.
Since you need the age in years it should look like DateDiff(0, [dateOfBirth], Today()). Also remove the extra square braces. This gave me the desired result.

Since you are getting the result as 8096, try and check a few things.
- Just use Today() in a new Calc stage and see whether you get today's date. I once encountered a situation where this function was giving a wrong today's date.
- Also check what is the datatype of the dateOfBirth DataItem? Make it to Text or Date. Both have given me the correct results.
 
Last edited:

jessica.leite

New Member
Hi,

I see this quite often on the Robiquity Bootcamp. I think the issue is related to the collection you’re looking at.

Is Coll1 the collection you’ve input into the queue, rather than the collection used by Get Next Item to store the current case?

Regards
Rob


Thanks!! I had exactly the same problem!
 

ikaybee

New Member
Hi @Cris800

Why is there a 12 in your function? Instead of:

DateDiff(0, [12,[dateOfBirth], Today()) it should be DateDiff(0, [[dateOfBirth], Today())

Could you provide a screenshot of your process please?

Deprecated means that something is generally discouraged from use because it's usually been superseded by something else. I'll look into this further.

Rob


So does this work if the person is born in an earlier month.

E.g DateDiff(0, "01/05/2000", "10/05/2018") will still evaluate to 18, even though the person's birthday is on 10/05, using 0 as interval only works with date. How do you check based on the exact day such that it evaluates on 18 only after "10/05/2000"
 

TonyMotala

New Member
I have a problem with the DateDiff( ) function, I am using a decision stage to find if the date stored in the data item named Birth is greater than 18. I used the expression as follows DateDiff(0, [Birth], Today()) > 18. The following error is returned.
View attachment 1535623645513.png
 

Attachments

  • 1535623592201.png
    11 KB · Views: 57

VJR

Well-Known Member
I have a problem with the DateDiff( ) function, I am using a decision stage to find if the date stored in the data item named Birth is greater than 18. I used the expression as follows DateDiff(0, [Birth], Today()) > 18. The following error is returned.
View attachment 1806
Hi TonyMotala,

Everything seems right with the usage. See if the Birth data item is correctly spelt and if there are no leading and trailing spaces and use drag and drop of data items versus typing by hand and then adding square brackets. Also check the data type of the Birth data item and make it a Date.
 
Top