Print Page | Close Window

DateDiff -> HH:MM:SS

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22562
Printed Date: 29 Apr 2024 at 12:08am


Topic: DateDiff -> HH:MM:SS
Posted By: NCGOV
Subject: DateDiff -> HH:MM:SS
Date Posted: 16 Mar 2018 at 4:19am
Formula to calculate the difference in HH:MM:SS between two date time fields.

How many Hours, Minutes, Seconds worked

{unit.onduty} {unit.offduty}



Replies:
Posted By: DBlank
Date Posted: 16 Mar 2018 at 6:08am
you have to do a datediff using seconds as the increment then you can use a formula field to change result of total seconds to display like HH:MM:SS.
There are a ton of those formulas posted already.


Posted By: NCGOV
Date Posted: 16 Mar 2018 at 6:38am
This is the formula(s) I have

CStr(Round(DateDiff ("n", {unit.onduty}, {unit.offduty}) \ 60 ),0) +':'+
CStr(Round(DateDiff ("n", {unit.onduty}, {unit.offduty}) MOD 60 ),0)

AND/OR

DateDiff ("H", {unit.onduty}, {unit.offduty})

What do I need to do differently to make it display as HH:MM:SS?




Posted By: DBlank
Date Posted: 16 Mar 2018 at 7:41am
if you never can exceed 24 hours try

time(dateadd('n',(DateDiff ("n", {unit.onduty}, {unit.offduty})),datetime(1900,1,1,0,0,0)))
and set the result to display as military time


Posted By: NCGOV
Date Posted: 16 Mar 2018 at 9:01am
This formula seems to work....

TimeValue ({unit.offduty}-{unit.onduty})


Posted By: DBlank
Date Posted: 16 Mar 2018 at 9:22am
what are some example values inside {unit.offduty} and {unit.onduty}


Posted By: NCGOV
Date Posted: 16 Mar 2018 at 9:47am
Just date and time ...03/16/18  08:00:00



Print Page | Close Window