Skip to main content
Post a question

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

DIFFINDAYS ERROR

Like (0) ShareShare
ReportReport
Posted on 3 Sep 2015 21:30:37 by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on 07 Sep 2015 at 01:51:03
    RE: DIFFINDAYS ERROR

    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.

  • Suggested answer
    Hamzeh Zawahreh Profile Picture
    Hamzeh Zawahreh 3,674 on 06 Sep 2015 at 19:10:50
    RE: DIFFINDAYS ERROR

    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/

  • Suggested answer
    Deeps Profile Picture
    Deeps 1,875 on 06 Sep 2015 at 13:31:42
    RE: DIFFINDAYS ERROR

    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.

  • MarkR_B Profile Picture
    MarkR_B 465 on 05 Sep 2015 at 05:24:29
    RE: DIFFINDAYS ERROR

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on 05 Sep 2015 at 01:44:55
    RE: DIFFENDAYS ERROR

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

    /:>

  • Community Member Profile Picture
    Community Member Microsoft Employee on 04 Sep 2015 at 17:34:16
    RE: DIFFENDAYS ERROR

     The same issue occurs with DIFFINWEEKS AND DIFFENMONTHS.

  • Community Member Profile Picture
    Community Member Microsoft Employee on 04 Sep 2015 at 17:22:18
    RE: DIFFENDAYS ERROR

    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. 

  • P. R. M Profile Picture
    P. R. M 739 on 04 Sep 2015 at 05:38:22
    RE: DIFFENDAYS 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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on 04 Sep 2015 at 04:45:25
    RE: DIFFENDAYS ERROR

    I'll Check their Form Fields. Thanks.

  • Deeps Profile Picture
    Deeps 1,875 on 04 Sep 2015 at 04:26:02
    RE: DIFFENDAYS ERROR

    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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,286 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,064 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans