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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / DiffInDays() not worki...
Power Apps
Unanswered

DiffInDays() not working in calculated field when date field has "Date Only" behavior

(0) ShareShare
ReportReport
Posted on by 311

In my model-driven app dataverse, I have a Date Only field (Birth Date) that was using the behavior of "User Local".  That field was also accessed in the calculated field formula for another field:

 

DiffInDays(spear_birthdate, Now())

 

Now I have to change the Birth Date behavior type to "Date Only" to avoid timezone issues.  But that breaks the DiffInDays calculated logic.  How can I change that formula to work again?  Is there a way to "cast" Birth Date as a date/time value for the formula?

I have the same question (0)
  • ChrisPiasecki Profile Picture
    6,422 Most Valuable Professional on at

    Hi @tschopp,

     

    When you change the behavior of a Date/Time column, you'll want to go into any dependant calculated columns, business rules, and workflows and deactivate/reactivate and resave them so they get the latest behavior metadata from your date field.

     

    More info here.

     

    ---
    Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

  • Ram Prakash Duraisamy Profile Picture
    5,593 Super User 2025 Season 2 on at

    Hi @tschopp,

     

    Hope the field is not Timezone independent.

  • tschopp Profile Picture
    311 on at

    @ChrisPiasecki Yes, thank you.  That's what I was doing.  Except when I open the calculated field formula and try to save it, I get this error:

     

    You can't use Now(), which is of type DateTime, with the current function.

     

    Except I don't think the "Now()" part is the issue.  The DiffInDays() function works fine with Now() when the other value is a date only field with the "User Local" behavior set.

  • Verified answer
    MayankP Profile Picture
    464 on at

    @tschopp  have you looked at this one http://nycrmdev.blogspot.com/2015/05/new-calculated-field-functions-in.html?

     

  • tschopp Profile Picture
    311 on at

    @MayankP I guess that's how it must be done for now:

    "The trick to getting UTC time in this case, is to first create the datetime field as User Local, fill in the calculation field action, and only then change the datetime behaviour to Time Zone Independent."

     

    The same seems to be true for Date-Only fields.  BTW, even though I cannot edit and save my existing calculated field formulas without that error, they do seem to be working.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard