Compare Dates in BPM

I am trying to compare two dates and then choose the lower of the two dates in a BPM. One date is in a UD table and one is entered by a user, so will be in BPMData.Date03. I have tried putting this in a Condition and a Set Argument/Variable, but nothing seems to work for me.

When I try to do it simply and just compare the dates, I get the error message “BPM007: Result of expression cannot be compared with variable of ‘System.DateTime?’ type”.

I have tried converting the dates to Integers or Decimals, through an “If, then” statement like below and then have the result be the date field I want, but get the error message “error BPM006: Result of expression cannot be assigned to variable of ‘System.DateTime?’ type”.

((Convert.ToDecimal(dsUD12UD12Row.Date01)) > (Convert.ToDecimal(callContextBpmData.Date03))) ? callContextBpmData.Date03 : dsUD12UD12Row.Date01

I am new to BPMs in E10, but have worked with them in E9 and do not know C#. I would appreciate any help in getting this to work.

Also, if there is any good documentation out there that would help me understand the BPMs in E10 better, please let me know where it is.

Thanks!
Paula

1 Like

I don’t think it should be as hard as you are making it. I think you might have something more simple set up wrong. Can you show some screen shots of your BPM?

Converting a date to a decimal is not going to work. I would recommend get some basics in before you tackle any of this if you admittedly don’t know C# lots of resources online here is one to get you started if you want to spend some money Team Treehouse is awesome!

2 Likes

Also, your help files, or Epic Web has the tools guide which will introduce you to some BPM’s. I would spend some time with that.

1 Like




Thanks Brandon. The first image is just of my whole workflow. The next three are of the area I am having the problem.

Thanks Joshua. I will check that out.

Can I ask why you are converting the dates to integers/decimals?

Only because it didn’t seem to work to just use the dates as they were, so was trying different things. I definitely don’t need to do that.

What does it do when you try the just the dates themselves?

I am able to save within the design view, but when I get back out to the Method Directives screen and hit save, I get the “error BPM006: Result of expression cannot be assigned to variable of ‘System.DateTime?’ type” error.

did you use the check syntax button on the expression editor?

Yes, is says “Syntax is OK”.

Because you are using nullable object types you are going to need to do some casting and conversions to different types to get it done. Under normal circumstances you should be able to directly compare dates, but the nullable types play by different rules at runtime.

The issue is that one of your date is a nullable and can’t be compared to a non nullable date. Look up

Perhaps you could shed some extra light on this? I am running into this issue now.

I’m confused about how a datetime can be nullable and what exactly I am supposed to do, to convert it. As far as the bit of research i have done there is no conversion tool to just make something non-nullable.

The link jose posted above should explain what it is and how to work with it. Most any type, when typed as such, can contain a null value DateTime?, Boolean?, etc

I was very confused how to implement the above article within expression editor. However it did help me further google my issue. Which lead me to the always helpful stack overflow. Ended up being able to just use Convert.ToDateTime() to solve this problem.

1 Like

A lot of times you can just straight cast it too

((DateTime)BpmFunc.AddInterval(BpmFunc.Now,-1,IntervalUnitYears))

As an aside we try to avoid BpmFuncs and use their real C# counterparts when doing a custom expression. I can’t remember exact cases of when or why but we have had those mess us up a few times and the ‘real’ C# versions worked better without the EpiMagic.