Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Exclude Weekends in calculation Post Reply Post New Topic
Author Message
dila
Newbie
Newbie


Joined: 30 Jun 2012
Online Status: Offline
Posts: 2
Quote dila Replybullet Topic: Exclude Weekends in calculation
     Posted: 30 Jun 2012 at 11:48pm
Hello,
 
I am working on a report and I need to exclude weekends (i.e saturday and sunday) in length of outage.  Can anyone please tell me how this could be done?
 
Thanks,
dila
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 01 Jul 2012 at 11:31pm
Try this;
 
DateTimeVar startdate := {table.datefield1};
DateTimeVar enddate := {table.datefield2};


Numbervar weekdays:=


Datediff("d", startdate, enddate) -
Datediff("ww", startdate, enddate, crSaturday)-
Datediff("ww", startdate, enddate, crSunday);

weekdays
 
Regards,
Ryan.
IP IP Logged
dila
Newbie
Newbie


Joined: 30 Jun 2012
Online Status: Offline
Posts: 2
Quote dila Replybullet Posted: 03 Jul 2012 at 9:48pm
Whoa..  it works!  Thank you very much.
 
What if I also need to include hours and mins in the calculation?
 
..dila
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