Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Identifying Sequential Weekends Post Reply Post New Topic
Author Message
criso
Newbie
Newbie


Joined: 25 Oct 2012
Online Status: Offline
Posts: 2
Quote criso Replybullet Topic: Identifying Sequential Weekends
     Posted: 25 Oct 2012 at 2:50am
I'm new here and a Crystal novice but  hoped someone could help me with a report I am currently designing.

The report is designed to show various hours, shifts and activities for people and is nearly done but there is one field that I am having trouble with.

There is a flag in the database which shows when a weekend day has been worked. 
So I can easily retrieve a list of start and end times for each shift that took place on a weekend. 

From this I can calculate number of weekends and weekends off.


However I need to flag how many sequential weekends were worked and need a formula to calculate this.


Any suggestions gratefully received
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 25 Oct 2012 at 7:38am
well, first, do they ALWAYS work the entire weekend? That could make a minor difference

do a running total, and evaluate two things, if flag='y' and I would have a sql expression that would evaluate if 7 days prior to that flagged date also has a flag for that weekend.

That make sense?
IP IP Logged
criso
Newbie
Newbie


Joined: 25 Oct 2012
Online Status: Offline
Posts: 2
Quote criso Replybullet Posted: 25 Oct 2012 at 11:59am
Originally posted by comatt1

well, first, do they ALWAYS work the entire weekend? That could make a minor difference


I believe the entire weekend but presumably once I have the formula I can tweak the interval it checks.

Sorry but need a bit more detail.  What formula can I use to see if the flag exists in the previous 7 days.

Dates in the db are stored in unix time if that makes a difference but I also have them converted to date format too.


IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 26 Oct 2012 at 4:30am
the only issue I have had with UNIX times is that in my progress language nulls are allowed, outside that, I dont see an issue.

I would create a shared variable in a formula to hold the last date of the last flagged weekend
formula one - group header

shared datevar lastweekend:='';
if flagged = true then
lastweekend:={date};

lastweekend

create a running total

look at the formula

evaluate

datediff('w',@formula, {currentdate})

reset on group

if report total = 1 then it was consecutive..

Sorry dont have much time to fully answer today. Hope this gets you a start.
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