DateDiff months error when using in assign activity

Hello together,
I want to read a date in excel and calculate the date difference in months which I would like to assign to a variable.

Problem: My formula works in Log message but in assign activity the formula doesn’t work.

  • DateDiff: Int32
  • Formula: Test is the variable passed on from Excel.
    DateDiff(DateInterval.Month, Convert.ToDateTime(Test),Convert.ToDateTime(DateTime.Now))

Error message (translated): The expression is no array or method and cannot have an argument list.

Thanks for your help!


Naming a variable the same as a method-name is a very bad practice
If your variable has a properly name it will work :wink:


@mwerner yes you were right :smiley: Didn’t notice it for a long time^^
In addition if using a integer one has to convert to Int, too.

convert.ToInt32(DateDiff(DateInterval.Month, Convert.ToDateTime(Test),Convert.ToDateTime(DateTime.Now)))

Just some additions to the above code:

In addition if using a integer one has to convert to Int, too.

The method returns a long-value. Why not to use this instead of INT?


Is there any reason you convert a datetime to a datetime? :smile:


could be replaced by


1 Like

Ok I didn’t know the “long” type.
Datetime: No reason :smiley:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.