When using DIFFINDAYS for a calculated date time field, a user is trying to compare two custom date time fields.
DIFFINDAYS(New_Customdate, new_customdate2)
It returns the error " You Can't set the value DIFFINDAYS(New_Customdate, new_customdate2) Which is a type of integer to type DateTime.
Same error if you use DIFFINDAYS(New_Customdate, NOW())
Returns: It returns the error " You Can't set the value DIFFINDAYS(New_Customdate, NOW()) Which is a type of integer to type DateTime.
But the following works:
DIFFINDAYS(createdon, NOW())
So that's a system field on the entity. Why will this not work using two custom date fields or a custom date field with NOW()?
*This post is locked for comments
Well, I finally got some sleep or rather I slept on why I was making a mistake. It came to me Friday.
Early in 2015 , the first time I used the Diffindays was with the diffindays(createdon, NOW()) example and it worked. The problem was that it got in my mind that this was comparing two date fields to get a numerical difference and the field I created was a Date field. So that worked. But I was wrong. The error is not in the function. It was me. So here is the point. I'm looking for a value or number, the difference between two date/time fields, but I was trying to put the results in a date time field the way, DIFFINDAYS(createdon, NOW()) shows the results in a date/time field. But that's wrong.
If you want a number ask for a number so the type whole number for a field allows for result to be stored. With that everything works
Thanks for letting me bounce this off of everyone.
Hi
The calculated field has to be of data type WholeNumber not DateTime. DIFFINDAYS will return an integer value not a date.
I hope it clears.
I would guess that there could be a format issue. Alert the attributes to screen and see if you can visually see the difference.
A reminder. I am typing Diffindays in the formula. Pardon the spelling error.
/:>
The same issue occurs with DIFFINWEEKS AND DIFFENMONTHS.
So createdon and Now() work fine. That's the example in the MSDN site.
I did that in the client online site and in the a new trial made two weeks ago.
So I just tested again.
In a new CRM 2015 online instance, I customized the account entity with two new date/time fields.
new_deploymentdate and new_trainingdate.
They are added to the form.
Yes, it is published. Changes are saved and published.
Fields contain data.
I created two date time fields.
The types are date /time.
Diffindays(new_deploymentdate, new_trainingdate)
The calculated date/time field is set to the date/time.
All are user local.
Same error.
Hi,
Can you please confirm CRM version (CRM 2015 or CRM 2015 update1)?
Recently, I used "DiffInDays" function in calculated fields with custom date fields, Now() and CreatedOn. It was working fine without any errors. I did in CRM 2015 update1.
Regards,
Prasad Reddy Mamilla.
I'll Check their Form Fields. Thanks.
Are you sure data type for your custom fields is Date? Please check other properties of your custom fields also like is it Date only or Date Time etc? They should match when comparing with other date.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,902 Super User 2024 Season 2
Martin Dráb 229,316 Most Valuable Professional
nmaenpaa 101,156