Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: sum time fields Post Reply Post New Topic
Author Message
spl1
Newbie
Newbie
Avatar

Joined: 18 Jun 2009
Location: United Kingdom
Online Status: Offline
Posts: 20
Quote spl1 Replybullet Topic: sum time fields
     Posted: 04 Nov 2009 at 7:02am
Hi
I have a report which holds detail rows per event date, within each detail row I have two datetime fields which I have then used:-
time(datetime1 - datetime2) to give me the difference in IN and OUT times.
 
The time given is a time field, which I want to sum per group and then by report. If I use the "insert summary" option I get count etc not sum.
 
I've thought about shared timevar but this would need to reset to zero at each change of group and if I do shared timevar:=0   doesnt work, if i use shared timevar:=00:00:00  it asks me to insert )
 
Any idea's....
Many thanks in advance
Sarah
 
Sarah
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Nov 2009 at 7:23am

if you do datediff('n',time2,time1) it will give you total minutes per record which can be summed for total minutes of any group level.

IP IP Logged
spl1
Newbie
Newbie
Avatar

Joined: 18 Jun 2009
Location: United Kingdom
Online Status: Offline
Posts: 20
Quote spl1 Replybullet Posted: 04 Nov 2009 at 7:36am
Thank you - is there a quick way to convert the minutes back to hh:mm ??
Sarah
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Nov 2009 at 7:57am
will it ever go over 24 hours?
if so how do you want that displayed?
 
IP IP Logged
spl1
Newbie
Newbie
Avatar

Joined: 18 Jun 2009
Location: United Kingdom
Online Status: Offline
Posts: 20
Quote spl1 Replybullet Posted: 04 Nov 2009 at 8:06am
The time difference being shown will not go over 24hrs, as it is the time worked by an individual on that day. I would like the group total to convert from minutes to hh:mm
However, I've just looked around and noticed that other members have been advised to sum(field,group)/60 - but my group is the event day which in the group sort select I've set to print for each week so if I try this method Crystal responds need the group to match formula
Also noticed that others have used the totext(({table.visitTime}-remainder({table.visitTime},60))/60) + ":" + totext(remainder({table.visitTime},60))  which gives me an answer of ie 945mins becomes 14.00 ; 00.05
 
Thank you for your help in advance.
Sarah
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Nov 2009 at 8:24am
There are a number of ways you can achieve this. The remainder process is one of those.
Since your SUM will never be more than 24 you can do a dateadd(minutes, SUM(formula),any date at midnight here) and then format this as hh:mm
 
example:
Place in footer, right click and select format field
select Date and Time tab
choose 13:23 option
click OK
if you want lead 0 on hours use the customize button to change that formatting in there.
 
IP IP Logged
spl1
Newbie
Newbie
Avatar

Joined: 18 Jun 2009
Location: United Kingdom
Online Status: Offline
Posts: 20
Quote spl1 Replybullet Posted: 04 Nov 2009 at 9:58am
Apologies..after trying this method I "fully" understand your last question.
Yes, the sum of hours worked could amount to more than 24, basically all I require the formula to do is for using the remainder version which totalled the hours worked into minutes correctly, ie 3018. Which I need to equate back 50hrs 18mins...
Sorry
Sarah
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Nov 2009 at 10:17am
Using the 'remainder' option from above you could use:
 


Edited by DBlank - 04 Nov 2009 at 10:18am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum