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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Can you use Date field...
Power Apps
Answered

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:
  • 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
    Microsoft Employee 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
    Microsoft Employee 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard