Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
Answered

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

(0) ShareShare
ReportReport
Posted on by 306

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?

  • tschopp Profile Picture
    306 on at
    Re: DiffInDays() not working in calculated field when date field has "Date Only" behavior

    @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.

  • Verified answer
    MayankP Profile Picture
    462 on at
    Re: DiffInDays() not working in calculated field when date field has "Date Only" behavior

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

     

  • tschopp Profile Picture
    306 on at
    Re: DiffInDays() not working in calculated field when date field has "Date Only" behavior

    @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.

  • Ram Prakash Profile Picture
    5,166 Super User 2025 Season 1 on at
    Re: DiffInDays() not working in calculated field when date field has "Date Only" behavior

    Hi @tschopp,

     

    Hope the field is not Timezone independent.

  • ChrisPiasecki Profile Picture
    6,389 Most Valuable Professional on at
    Re: DiffInDays() not working in calculated field when date field has "Date Only" behavior

    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.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Microsoft Dataverse

#1
stampcoin Profile Picture

stampcoin 17

#2
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

Overall leaderboard

Featured topics