Incorrect datatype for operator

Hi

I need to get the business days excluding Saturdays, Sundays, and 10 holidays. I have written the below formula however on execution getting error message “Incorrect datatype for operator…”

FIELD currDate:=@Today;

FIELD currYear := @Right(@Text(currDate);4);

FIELD holidays := holidays;

@If(dtFromDate = “”;@Do(@Prompt([Ok]; “Alert” ; “Kindly select from date”);@Return(“”));“”);

@If(dtToDate = “”;@Do(@Prompt([Ok]; “Alert” ; “Kindly select to date”);@Return(“”));“”);

@If(dtFromDate > dtToDate;@Do(@Prompt([Ok];“Error Alert”;“To Date cannot be less than From Date”);@Return(“”));“”);

x := @DbLookup(“”:“NoCache”;“”:“TITANManESP.nsf”;“Holidays”;currYear;“HolidayDateAll”);

@For(n := 1;n <= 6;n := n + 1; holidays = holidays + “[” + @Explode(x[n]) + “]” + “:” );

@Prompt([Ok];@Text(@BusinessDays(dtFromDate; dtToDate; 1 : 7; holidays));“Business days in 2009”);

@Command([FileSave]);

Thanks,

Sanjay

Subject: The operator is “+”…

…and the reason you get an error is that holidays is a date value and you tried to add a string to it.

I also don’t understand why you’re using @Explode on a single date value – what is that supposed to do?

Please investigate the : operator, and think about where you should use parenthesis to control the order of evaluation.

What makes you think there are always exactly 6 values in your lookup data?

Subject: holidays not excluding in @businessdays

Hi Andre

Thanks you reply.

I have below date values in “HolidayDateAll” field.

“01/01/2009”

“05/26/2009”

“07/04/2009”

“09/01/2009”

“11/27/2009”

“12/25/2009”

which I need to exclude in @businessdays to calulate no of days between two dates. Now its working fine but it is not excluding holidays.

here is my code:


FIELD currDate:=@Today;

FIELD currYear := @Text( @Year(currDate));

FIELD holidays := holidays;

@If(dtFromDate = “”;@Do(@Prompt([Ok]; “Alert” ; “Kindly select from date”);@Return(“”));“”);

@If(dtToDate = “”;@Do(@Prompt([Ok]; “Alert” ; “Kindly select to date”);@Return(“”));“”);

@If(dtFromDate > dtToDate;@Do(@Prompt([Ok];“Error Alert”;“To Date cannot be less than From Date”);@Return(“”));“”);

x := @DbLookup(“”:“NoCache”;“”:“TITANManESP.nsf”;“Holidays”;currYear;“HolidayDateAll”);

@For(n := 1;n <= 6;n := n + 1; holidays = holidays + “[”+@Explode(x[n])+“]” + “:” );

@Prompt([Ok];@Text(@BusinessDays(dtFromDate; dtToDate; 1 : 7; @TextToTime(holidays)));“Business days in 2009”)


Thanks

Sanjay