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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working Days Mis-Calculating

Status
Not open for further replies.

Jeremiah31

Programmer
Nov 7, 2006
31
0
0
US
I tried searching on the forum, if I overlooked the answer please forgive.

When I input my starting date value and leave the end as current date, the total number of working days is a six digit number.

The Start date is based on a three digit (numeric value) concaterize as a date value

Date({iSeriesSQL_FADC_Unfianlized_Keyrec_Trailer.INYRYEAR},
,{iSeriesSQL_FADC_Unfianlized_Keyrec_Trailer.INYRMO},
,{iSeriesSQL_FADC_Unfianlized_Keyrec_Trailer.INYRDA});

I think the problem has to do with formula for start date, I'm a little lost in what to do.


WhilePrintingRecords;
//Set the values of Start Date and End Date
DateVar StartDate := Date({iSeriesSQL_FADC_Unfianlized_Keyrec_Trailer.INYRYEAR},{iSeriesSQL_FADC_Unfianlized_Keyrec_Trailer.INYRMO},{iSeriesSQL_FADC_Unfianlized_Keyrec_Trailer.INYRDA});
DateVar EndDate := CurrentDate();

//Find out the difference in days and subtract the weekends
NumberVar DaysDiff := DateDiff("d",StartDate,EndDate) -
DateDiff("ww",StartDate,EndDate,crsaturday) -
DateDiff("ww",StartDate,EndDate,crsunday);

//Create an array of Holiday dates
Local DateVar Array Holidays := MakeArray(
Date(2007,01,01),
Date(2007,01,02),
Date(2007,12,25),
Date(2007,12,26),
Date(2007,07,07));

//Loop through the array checking if each holiday is within the dates
Numbervar Counter := 0;
While UBound(Holidays) <> Counter do
(Counter := Counter + 1;
if Not(dayofweek(Holidays[Counter]) in [1,7]) and
Holidays[Counter] in StartDate to EndDate then DaysDiff := DaysDiff -1;);

//Display result to 0 decimal places and no thousand separator
totext(DaysDiff,0,"");
 
You'll have to show us a sample of each of the fields in the start date formula.

-LB
 
All three fields are numberic values.

The date looks like 2/12/7

I tried using the dateSerial function, the date shows as
2/12/7




 
Create a formula of:

stringvar array MyDate:= split({table.field},"/");
cdate(val(MyDate[3])+2000,val(MyDate[1]),val(MyDate[2]))

-k
 
I meant for you to show sample of each of the following, so we could also tell which was which:

{iSeriesSQL_FADC_Unfianlized_Keyrec_Trailer.INYRYEAR}{iSeriesSQL_FADC_Unfianlized_Keyrec_Trailer.INYRMO}{iSeriesSQL_FADC_Unfianlized_Keyrec_Trailer.INYRDA}

The way it "looks" depends upon how you formatted the date, so it doesn't tell much.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top