Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Which days are work days in a given range Post Reply Post New Topic
Author Message
zach18
Groupie
Groupie
Avatar

Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
Quote zach18 Replybullet Topic: Which days are work days in a given range
    Posted: 22 Jun 2011 at 4:38am
Is there a built in function that will tell me which days are work days? this is what i mean,

If I were to choose today's date (6/14/2011), it will give me any inspection numbers clocked out today. This lead time includes weekends. So if I had a customer start a project on the 10th (Friday) and finish it today; it would show it took about five days, instead of three.
Using Crystal Report 2008
www.zachtech.us
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 22 Jun 2011 at 5:04am
you could try dayofweek function, with it help you could exclude (sat,sun) from your results  (Sun = 1, Sat = 7)
IP IP Logged
zach18
Groupie
Groupie
Avatar

Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
Quote zach18 Replybullet Posted: 23 Jun 2011 at 7:23am
here is my solution

if({@timeDiff} >= 35) then
{@timeDiff} - 10
else if({@timeDiff} >= 28) then
{@timeDiff} - 8
else if({@timeDiff} >= 21) then
{@timeDiff} - 6
else if({@timeDiff} >= 14) then
{@timeDiff} - 4
else if({@timeDiff} >= 7) then
{@timeDiff} - 2
else if(DayOfWeek({Command.DateTimeStamp}) < DayOfWeek({Command.CreatedDate})) then
{@timeDiff} - 2
else
{@timeDiff}

for an explanation go here to by website to read up on it.
explanation

Edited by zach18 - 23 Jun 2011 at 7:23am
Using Crystal Report 2008
www.zachtech.us
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 23 Jun 2011 at 9:42am
What if a client spent 60 days on a project?
It wouldn't be 10 days worth of weekends.

Also, here is a trickier case:

Suppose I started working on wednesday 8th and finished on monday 27th.

Thus, without deducting any weekends, I have apparently spent 20 days on the project.

2 weekends have definitely passed (so Wed 22nd would be the start of my third week) but then in the remaining 6 days, I happened to run into another weekend.

This would probably need to be considered as well.

I also thought about this problem for some time at one point: http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=13368&KW=

Edited by Keikoku - 23 Jun 2011 at 9:51am
IP IP Logged
zach18
Groupie
Groupie
Avatar

Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
Quote zach18 Replybullet Posted: 23 Jun 2011 at 9:50am
well then the numbers will be off, this solution worked for the extent of my project. that solution isnt the best and as you pointed out has a flaw. how would you go about fixing it? other than making a lot more if statements
Using Crystal Report 2008
www.zachtech.us
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 23 Jun 2011 at 9:53am
Basically, the total number of weeks that have passed and the remaining days should be calculated separately.

But it will only be off by a maximum of 2 days so if you do not need such accuracy (ie: auditing) then it doesn't matter.
IP IP Logged
zach18
Groupie
Groupie
Avatar

Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
Quote zach18 Replybullet Posted: 23 Jun 2011 at 9:53am
this is a much better solution
Using Crystal Report 2008
www.zachtech.us
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.