Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Working Hours Post Reply Post New Topic
Author Message
slash85
Newbie
Newbie


Joined: 31 Mar 2009
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote slash85 Replybullet Topic: Working Hours
     Posted: 11 Jun 2009 at 10:49am
Hi All,
 
I've been using this formula to monitor the amount of hours between two dates that have elapsed excluding weekends:
 
 
(
DateDiff ("s", {campaign.date_approved}, {campaign.date_closed}) -
    (DateDiff ("ww", {campaign.date_approved}, {campaign.date_closed}, crSaturday)*24*60*60) -
     (DateDiff ("ww", {campaign.date_approved}, {campaign.date_closed}, crSunday)*24*60*60)
) /60/60;
 
 
But i've now been told that the hour calculations should only apply to working hours 9 to 5. 
 
Does any one know how i would do this?  I was thinking of something like subtracting 80 from the total (16 none workable hrs per day * 5 days) but not sure if this is correct?
 
Any ideas any1?
 
Many Thanks,
Slash.
IP IP Logged
BrianL
Newbie
Newbie


Joined: 16 Feb 2009
Location: United States
Online Status: Offline
Posts: 6
Quote BrianL Replybullet Posted: 11 Jun 2009 at 2:02pm
Hi Slash,
 
Do you need to convert it to seconds then back to hours?  Or would something like:
(
DateDiff ("d", {campaign.date_approved}, {campaign.date_closed}) -
    (DateDiff ("ww", {campaign.date_approved}, {campaign.date_closed}, crSaturday) -
     (DateDiff ("ww", {campaign.date_approved}, {campaign.date_closed}, crSunday))
) *8;
work?  This one is just finding the number of work days and multiplying by 8.
 
Hope this helps,
Brian
IP IP Logged
slash85
Newbie
Newbie


Joined: 31 Mar 2009
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote slash85 Replybullet Posted: 12 Jun 2009 at 1:01am
Hi Brian,
 
Thanks for the reply.
 
What i'm trying to achive is calculate the number of working hours a campaign has taken to run.  Which i then plot on a graph eg:
 
Campaign X 15hours
Campaign Y 12Hours
 
and so on.
 
 
Example:
 
A campaign could be started on a Wednesday and finish on a Monday.  What i need to sum is the number of 9-5 hours that have elapsed exluding Sat and Sun.
 
Make Any sense?
 
Thanks,
Slash.
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