web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

DIFFINDAYS ERROR

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Deeps Profile Picture
    1,875 on at

    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.

  • Community Member Profile Picture
    on at

    I'll Check their Form Fields. Thanks.

  • P. R. M Profile Picture
    739 on at

    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.

  • Community Member Profile Picture
    on at

    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. 

  • Community Member Profile Picture
    on at

     The same issue occurs with DIFFINWEEKS AND DIFFENMONTHS.

  • Community Member Profile Picture
    on at

    A reminder.  I am typing Diffindays in the formula.  Pardon the spelling error.

    /:>

  • MarkR_B Profile Picture
    465 on at

    I would guess that there could be a format issue. Alert the attributes to screen and see if you can visually see the difference.

  • Suggested answer
    Deeps Profile Picture
    1,875 on at

    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.

  • Suggested answer
    Hamzeh Zawahreh Profile Picture
    3,674 on at

    dear cjspanburgh

     DIFFINDAYS will return an number value not a date.

    see this link:

    http://debajmecrm.com/2015/08/20/using-diffindays-to-auto-calculate-age-of-a-contact-dynamics-crm-2015-online-update-1/

  • Community Member Profile Picture
    on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans