cancel
Showing results for
Did you mean:
Impactful Individual

## DateDiff with Seconds

Thank you for taking the time to read my question.

I posted this question last week then answered my own question and marked it as answered... but as it turns out I didn't really answer my own question... So I'm re-posting

I have a start date and time and an end date and time and I'd like to use DateDiff() to determine the hours:minutes:seconds of elapsed time.

I have the following that... almost works.

If I have

Start = 5:22:33

End = 5:22:43

BUT if I have

Start = 4:15:55

End = 4:16:05

I can't seem to wrap my head around how to fix this...

My current formula is:

DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Hours) & ":" & Text(Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Minutes),60),"00") & ":" & Text(Mod(Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds),60),60),"00"))

Am I close? Do I need to do everything at the "Seconds" level and then calculate the minutes?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support

Hi @iwonder :

1\Start and End

Set(Start,DateTimeValue("2021-5-1 4:15:55"));Set(End,DateTimeValue("2021-5-1 4:16:05"));

2\The Formula:

With(
{DiffSeconds:Text(DateDiff(Start,End,Seconds))},
RoundDown(DiffSeconds/3600,0)&
":"&
Text(RoundDown(Mod(DiffSeconds,3600)/60,0),"00")&
":"&
Mod(Mod(DiffSeconds,3600),60)
)

Best Regards,

Bof

2 REPLIES 2
Impactful Individual

Just had an idea. This seems to work, but is there a better way?

Text(RoundDown(RoundDown(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds)/60,0)/60,0),"00") & ":" & Text(RoundDown(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds)/60,0)-(RoundDown(RoundDown(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds)/60,0)/60,0)*60),"00") & ":" & Text(Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds),60),"00")

Thanks

Community Support

Hi @iwonder :

1\Start and End

Set(Start,DateTimeValue("2021-5-1 4:15:55"));Set(End,DateTimeValue("2021-5-1 4:16:05"));

2\The Formula:

With(
{DiffSeconds:Text(DateDiff(Start,End,Seconds))},
RoundDown(DiffSeconds/3600,0)&
":"&
Text(RoundDown(Mod(DiffSeconds,3600)/60,0),"00")&
":"&
Mod(Mod(DiffSeconds,3600),60)
)

Best Regards,

Bof

Announcements

#### December 2023 User Group Update: Welcoming New Groups and Upcoming Events

A new month means it's time to celebrate and welcome the new user groups that have joined our community. We are excited to announce that we have more than 8 New Groups, which is no surprise after the amazing Microsoft Power Platform Conference. This month, we are breaking them out by the different community categories. If your group is listed here, give this post a kudo so we can celebrate with you! Don't forget to take a look at the many events happening near you or virtually! It's a great time of year to connect and engage with User Groups both locally and online.   Please Welcome Our NEW User Groups   Power Platform: PowerIT User Group: Nottingham Power Platform User Group: Bergen Power Platform User Group: Danmark Nashville Power Platform User Group Microsoft Ambassador Program y Mujer Latina Technolochicas NCWIT Community Copilot Studio:  Copilot User Group Italia Dynamics365: Dynamics User Group AdriaticDynamic 365 Azerbaijan   December User Group Events   01 Dec 2023 Aprendiendo Desarrollo web, creando mi primer power app y power page. 01 Dec 2023 Q4 Hybrid Philadelphia Dynamics 365 & Power Platform User Group Meeting05 Dec 2023APAC Dynamics 365 FastTrack Bootcamp - BI and Analytics07 Dec 2023Bay Area Power Platform Meetup: Learn, Share, and Connect07 Dec 2023Indiana D365/AX December User Group Meeting07 Dec 2023Dynamics User Group Meeting: Houston09 Dec 2023 December '23 - NEW Power Apps User Group Meeting - Online 12 Dec 2023December Cleveland Power Platform User Group Meeting12 Dec 2023 RW2 Data Stewardship Open Forum Discussion 13 Dec 2023  Black Country Power Platform User Group - December 2023 - West Midlands