Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Sum Weekend Days Post Reply Post New Topic
Author Message
martbar
Newbie
Newbie


Joined: 04 Apr 2012
Location: United States
Online Status: Offline
Posts: 15
Quote martbar Replybullet Topic: Sum Weekend Days
     Posted: 06 Nov 2012 at 6:59am
I have two dates
Call them "Start" and "End"
I would like to sum the number of weekend days (Sat, Sun) between the two dates. I assume this needs to be done using a While-Do loop and the dayofweek function but I do not know how to set it up.
 
can you help?
 
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 06 Nov 2012 at 7:45am
well, cheap way, you can always setup a sql.command object as opposed to just creating them report style, with (or create a sql expression)

(select datepart("weekday","B1PERMIT"."REC_DATE"))

the record name will be whatever you name sql expression

for runningtotal evaluate if that value

%SQLExp in [0,7]

I am not sure what is a weekend, either 6/7 someone else can verify
IP IP Logged
martbar
Newbie
Newbie


Joined: 04 Apr 2012
Location: United States
Online Status: Offline
Posts: 15
Quote martbar Replybullet Posted: 06 Nov 2012 at 10:34am
Unfortunately I don't know how to use SQL. I am pretty good with Crystal syntax.
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 07 Nov 2012 at 2:56am
create a sql expression put this in there.

(select datepart("weekday",{REFERENCED DATE FIELD}))

you don't have to do any new coding.
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 07 Nov 2012 at 2:58am
sql expressions can be referenced like normal fields in Running Totals.

evaluate {sql expression}

evaluate for - sql expression in [0,7] [6,7] whatever the weekend is

reset never
IP IP Logged
martbar
Newbie
Newbie


Joined: 04 Apr 2012
Location: United States
Online Status: Offline
Posts: 15
Quote martbar Replybullet Posted: 07 Nov 2012 at 3:04am
before I read the rest of the post I actually figured it out.
 
While Start <= End Do
(IF dayofweek(Start)= 7 Then Days:=1
ELSE IF dayofweek(Start) = 1 Then Days:=1
ELSE Days:=0;
Start:= Start + 1;
i:=i+Days;);
i
 
I will look into the SQL aspect as well
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