Skip to Content
avatar image
Former Member

calculating working days between two dates

hi expert

i have a built in calendar view with the field IsWorkingDays which stores 1 if it's a working day and 0 if it's a holiday/weekend and i have this formula in my report:

DateTimeVar StartDate:= CurrentDate;

DateTimeVar EndDate := {vw_wrkWorkOrders.RequiredByDate};

//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);

if Not({vw_astCalendarDeviations.IsWorkingDay}) in [1] and {vw_astCalendarDeviations.IsWorkingDay} in StartDate to EndDate then DaysDiff := DaysDiff - 1;

DaysDiff;

i'm trying to get the number of working days using the view

but i'm getting a boolean error in the If Not line

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • May 06, 2009 at 11:52 AM

    Adjust parenteses, I send two options because it is not explicity how you intend to use the "not":

    if (Not({vw_astCalendarDeviations.IsWorkingDay} in [1])) and 
       {vw_astCalendarDeviations.IsWorkingDay} in StartDate to EndDate then 

    or

    if Not ( ({vw_astCalendarDeviations.IsWorkingDay} in [1]) and
             ({vw_astCalendarDeviations.IsWorkingDay} in StartDate to EndDate) ) then 

    Regards, Fernando Da Ró

    Add comment
    10|10000 characters needed characters exceeded