Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array of dates 1

Status
Not open for further replies.

ewox420

Technical User
Jul 7, 2010
6
US
Hi, I have this formula called @holiday which count the number of holidays in a range of dates and it is working.

//{@holiday}
//Holiday Listing formula to go into the report header of the report.

WhileReadingRecords;
Local DateVar Start := Date(CovRJTim({HPD_Helpdesk.Create_Time}));
Local DateVar End := Date(currentdatetime);
Local Numbervar Hol;
DateVar Array Holidays := [Date (2011,05,30),
Date (2011,12,25),
Date (2011,12,31)];

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

//end of formula

But I have this field called {Holiday.HDate} which has the complete set of holidays date and the format is in mm/dd/yyyy.

How can i use this field in an array instead of the manual input of dates?

this is not working ---> DateVar Array Holidays := [Date({Holiday.HDate})];

Hope to here from you sirs....
 
You could set up the array in a subreport that you use in the main report header. In the sub, add the holidays table, and then create a formula for the detail section:

whileprintingrecords;
shared datevar array x;
numbervar i;
if not({table.date} in x) then (
i := i + 1;
redim preserve x;
x := {table.date}
);

You can suppress all sections WITHIN this sub, and then in the main report, right click on the subreport->format subreport->subreport tab to "suppress blank subreport".

Then you can reference the holidays in the main report by using a formula like this, for example:

whileprintingrecords;
shared datevar array x;
if {table.date} in x then
"Holiday"

-LB
 
Thank you for the reply. I still having problem using your formula. I need to get the count of holidays in a range of dates from created date to current dates for each tickets created per individual and will use it to subtract from pending days. for example:

Given: Memorial holiday = May 30,2011


Name Ticket Created Pending Count of
Number Date Days Open Holidays
-------------------------------------------------------
Joe Smith
0001 5/26/11 8 1
0026 5/27/11 7 1
0035 6/1/11 1 0
Larry Fox
0012 5/10/11 24 1
0023 6/2/11 1 0


Hope i explained it clearly.
 
After creating the subreport and subreport formula as mentioned earlier, add the following formula to the main report for the count of holidays:

whileprintingrecords;
shared datevar array x;
numbervar i;
numbervar j := ubound(x);
numbervar y := 0;
for i := 1 to j do(
if x in {table.date} to currentdate then
y := y + 1
);
y

-LB
 
Sorry for the late reply lbass.

Thank you very much! It works...
 
Hi llbass, have follow up question with this.

Since i already used the formula in getting the count of holidays. I have this condition
({@SLA_Time_in_number_hours}<=24) in record selection formula that is affected.

So i delete this condition in record selection and put this ({@SLA_Time_in_number_hours} > 24) into the formula of detail section to supress. I got the correct values but a'm having problem in getting the total count of a certain field PER GROUP.

Do you have any suggestion on how to get the total count per group which are not supress?
 
I'm not really following why suppression is better than removing the row in the selection formula, but anyway, if you are happy with the results, you could use a running total that does a count (not sure what your counting), with an evaluation formula like this:

{@SLA_Time_in_number_hours}<=24

Reset on change of group.

Place the running total in the group footer.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top