Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Datevalue field, hour value field, minute value field: combine to subtract from a different date value, hour value and minute value field

(0) ShareShare
ReportReport
Posted on by 187

Hi all,

 

Need some help. I have a Date_Time Value Column from Sharepoint as a card in my view form which looks as follows:
Screenshot 2021-05-20 at 22.12.04.png

 

The datacard looks like this:
Screenshot 2021-05-20 at 22.13.37.png

 

 

 

 

 

 

 

 

 

 

I have another datacard which looks exactly the same format wise, but the date/time will be further in the future compared to the above date/timestamp, e.g. May 23, 2021 01:50.

 

What I would like to achieve is the following:
May 23, 2021 01:50 - May 22,2021 11:00 = 14 hours and 50 minutes difference. 

 

How to approach this? seen some examples about datediff and time diff but the combination I could not easily make and I guess I need a combination of those 2 to fix the above. Any help much appreciated!

Categories:
  • debarbanson Profile Picture
    debarbanson 187 on at
    Re: Datevalue field, hour value field, minute value field: combine to subtract from a different date value, hour value and minute value field

    Dear @WarrenBelz ,

     

    Many thanks for your reply! I have used your code and this would be the result: 

    With(
            {
             wDiff:
             DateDiff(
                   DateValue2.SelectedDate +
                   Time(
                         Value(HourValue2.Selected.Value),
                         Value(MinuteValue2.Selected.Value),0
                   ),
                  DateValue5.SelectedDate +
                  Time(
                          Value(HourValue5.Selected.Value),
                          Value(MinuteValue5.Selected.Value),0
                  ),
                 Minutes
             ),
          },
         Text(RoundDown(wDiff/60,0)) & ":" &
         Text(Mod(wDiff,60))
    )

     

    However I get an error message from Powerapps:
    Expected colon. We expected a colon (:) at this point in the formula. I can't seem to figure out where this should be present, any clue?

     

    I have for the moment split up 2 labels, one with the date diff and the other one with the Text Rounddown and that works so I'm puzzled why the combined version does not work.

     

  • WarrenBelz Profile Picture
    WarrenBelz 145,304 on at
    Re: Datevalue field, hour value field, minute value field: combine to subtract from a different date value, hour value and minute value field

    Hi @debarbanson ,

    Something like this

    With(
     {
     wDiff:
     DateDiff(
     DateCard1.SelectedDate + 
     Time(
     Value(HourCard1.Selected.Value), 
     Value(MinuteCard1.Selected.Value), 0
     ),
     DateCard2.SelectedDate + 
     Time(
     Value(HourCard2.Selected.Value), 
     Value(MinuteCard1.Selected.Value), 0
     ),
     Minutes
     ),
     },
     Text(RoundDown(wDiff/60,0)) & ":" & 
     Text(Mod(wDiff,60)
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it 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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,304

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard