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 / calculate difer date a...
Power Apps
Answered

calculate difer date and time

(0) ShareShare
ReportReport
Posted on by 105

Hi,

would you advise how to calculate different dates and times in the power app?

Setayesh2_1-1645435956127.png

 

TotalTime is a text column in SharePoint

 

 

Thanks in advance

Categories:
I have the same question (0)
  • Setayesh2 Profile Picture
    105 on at

    I tried this function but it works for saved data. I need to calculate them at the time of change.

     

    With(
    {
    days: RoundDown(DateDiff(ThisItem.Start, ThisItem.End, Hours) / 24, 0),
    hours: Mod(RoundDown(DateDiff(ThisItem.Start, ThisItem.End, Minutes) / 60, 0), 24),
    minutes: Mod(DateDiff(ThisItem.Start, ThisItem.End, Minutes), 60)
    },
    days & " day(s), " & hours & " hour(s) and " & minutes & " minute(s)"
    )

  • Verified answer
    v-LilyW-msft Profile Picture
    Microsoft Employee on at

    Hi @Setayesh2 

    The data in your formula is the value obtained from the data source. If you want to obtain the value from the control, should refer to the value of the control.

    Please try following formula:

    With(
    {
    days: RoundDown(DateDiff(DateValue1.SelectedDate + Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     ),
     DateValue2.SelectedDate + Time(
     Value(HourValue2.Selected.Value),
     Value(HourValue2.Selected.Value),
     0
     ), Hours) / 24, 0),
    hours: Mod(RoundDown(DateDiff(DateValue1.SelectedDate + Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     ),
     DateValue2.SelectedDate + Time(
     Value(HourValue2.Selected.Value),
     Value(HourValue2.Selected.Value),
     0
     ), Minutes) / 60, 0), 24),
    minutes: Mod(DateDiff(DateValue1.SelectedDate + Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     ),
     DateValue2.SelectedDate + Time(
     Value(HourValue2.Selected.Value),
     Value(MinuteValue2.Selected.Value),
     0
     ), Minutes), 60)
    },
    days & " day(s), " & hours & " hour(s) and " & minutes & " minute(s)"
    )

    vLilyWmsft_0-1645601329070.png

    Hope the content above may help you.

    Best Regards

    If my reply helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Setayesh2 Profile Picture
    105 on at

    @v-LilyW-msft  thanks a lot. Would you also advise how I can control End date, to not set less than start date?

  • Verified answer
    v-LilyW-msft Profile Picture
    Microsoft Employee on at

    Hi @Setayesh2 

    If you want to set End Date should be greater than Start Date you can refer to below link to see if it helps.

    https://www.c-sharpcorner.com/article/power-apps-validation-end-date-and-time-should-be-greater-than-start-date-and/

     

    Hope the content above may help you.

    Best Regards

    If my reply helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 494

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
11manish Profile Picture

11manish 323

Last 30 days Overall leaderboard