Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date (Help Pls) Post Reply Post New Topic
Author Message
vpriyanka2001
Groupie
Groupie


Joined: 28 May 2009
Online Status: Offline
Posts: 59
Quote vpriyanka2001 Replybullet Topic: Date (Help Pls)
     Posted: 16 Apr 2013 at 4:21am
I have these formula displaying 2 weekdays date which has data.
 
04/18/2013            04/19/2013
 
But I need to change these 2 dates to show current 4 days of data.
eg: today is 16th APril
 
04/16/2013       04/17/2013     04/18/2013      04 19/2013 (Skipping weekends always.
 
if todays date is 04/18/2013
Then 04/18/2013       04/19/2013     04/22/2013      04/23/2013
 
*******weekend formula***************
((datediff ("ww", {TMS_Task.Create_Date}, ({TMS_Task.Create_Date}+3), crsaturday) +
datediff ("ww", {TMS_Task.Create_Date}, ({TMS_Task.Create_Date}+4), crsunday))+ 3 + {@NoOfDays})
 
*************Noofdays Formula**********
 
WhileReadingRecords;
Local DateVar Start := (date({TMS_Task.Create_Date}));
Local DateVar End :=(date({TMS_Task.Create_Date}) + {@Weekend} + 3);
Local NumberVar Weeks;
Local NumberVar Days;
Local Numbervar Hol;
DateVar Array Holidays;
Weeks:= (Truncate (End - dayofWeek(End) + 1
- (Start - dayofWeek(Start) + 1)) /7 ) * 5;
Days := DayOfWeek(End) - DayOfWeek(Start) + 1 +
(if DayOfWeek(Start) = 1 then -1 else 0)  +
(if DayOfWeek(End) = 7 then -1 else 0);
Local NumberVar i;
For i := 1 to Count (Holidays)
do (if DayOfWeek ( Holidays ) in 2 to 6 and
     Holidays in start to end then Hol:=Hol+1);
Hol


Edited by vpriyanka2001 - 16 Apr 2013 at 7:04am
IP IP Logged
joeg1962
Newbie
Newbie


Joined: 01 Mar 2013
Location: United States
Online Status: Offline
Posts: 35
Quote joeg1962 Replybullet Posted: 16 Apr 2013 at 7:27am
{Note: having Crystal issues, so just writing pseudo-code for an approach}

What about case on dayofweek?
dayvar = dayofweek(yourdate)
select {@dayvar}
case 1: //sunday
 begdt = today+1
 enddt = today+4
case 2: //monday
 begdt = today
 enddt = today+3
case 3: //tuesday
 begdt = today
 enddt = today+3
case 4: //wednesday
 begdt = today
 enddt = today+5
case 5 & 6 are same as 4
case 7: //saturday
 begdt = today+2
 enddt = today+5

By the way, holidays is a whole other thing! Do they exist in a table?
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