PeCour
1
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!

mwerner
2
Naming a variable the same as a method-name is a very bad practice
If your variable has a properly name it will work 
3 Likes
PeCour
4
@mwerner yes you were right
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)))
mwerner
5
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?
and
Is there any reason you convert a datetime to a datetime? 
Convert.ToDateTime(DateTime.Now)
could be replaced by
Now
1 Like
PeCour
6
Ok I didn’t know the “long” type.
Datetime: No reason 
Thanks!
1 Like
system
(system)
Closed
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.