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 / Can you use Date field...
Power Apps
Unanswered

Can you use Date fields in a calculation in a Model Driven App?

(0) ShareShare
ReportReport
Posted on by 509

Afternoon 

I have two date field in my entity - baseline start and baseline finish - and I want to show the duration in a third field - as seen below. I thought it would be a simple case of A - B but I'm getting the error below. Anyone got a workaround? All help gratefully received! 

DateCalculation.png

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @darrenfloyd666 

    You were close and it is simple. In the calculation use the DIFFINDAYS(StartDate,FinishDate) function.  

  • Verified answer
    v-xida-msft Profile Picture
    on at

    Hi @darrenfloyd666 ,

    Do you want to create a Calculated field in your Entity with date difference value from baseline start and baseline finish?

     

    Based on the formula/expression that you mentioned, I think there is something wrong with it. Currently, within CDS Entity, the '-' operator could not be used to calculate the difference between two different date time values.

     

    As an fixed solution, please take a try with the following workaround:

    3.JPG

    Action Formula Box set to following:

    DIFFINDAYS(createdon, crba2_duedate)

    On your side, you should type following:

    DIFFINDAYS(cr1b0_baselinestart, cr1b0_baselinefinish)

    Note: Above formula would calculate the Duration in Days Unit. If you want to calculate the Duration in other units, Hours, Minutes, Weeks, ..., please try the following function:

    DIFFINHOURS(cr1b0_baselinestart, cr1b0_baselinefinish)
    DIFFINMINUTES(cr1b0_baselinestart, cr1b0_baselinefinish)
    DIFFINWEEKS(cr1b0_baselinestart, cr1b0_baselinefinish)

    ...

    ...

    Note: There would have formula intelligence prompt in above Action Formula box when you type some key word, e.g. 'DIFF'

    Please consider take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • sutekh Profile Picture
    509 on at

    Thanks, I'll give that a go

  • v-xida-msft Profile Picture
    on at

    Hi @darrenfloyd666 ,

    Sure. If the solution I provided above is helpful in your scenario, please consider go ahead to click "Accept as Solution" to identify my reply as helpful.

     

    Best regards,

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