Remove Weekeends in Date Range

I have 2 dates startdate and enddate. I used @Explode to get the datelist in between the start and end dates. My problem is how can I exclude the weekend of that datelist.

Example:

startdate = Jan 4, 2008
enddate = Jan 8 2008
datelist = Jan 4, Jan 5, Jan 6, Jan 7, Jan 8

however Jan 5 and Jan 6 are weekends

how can I remove them from the list (using @Function) so my datelist will only contain Jan 4, Jan 7 and Jan 8?
makuletskiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
Okay, suppose this all works in Notes as I think it does, here you go:

list:= @Explode(your_range);
dlist:= @Text(list);
wdlist:= @Transform(dlist; "x";
   @If(@Modulo(@Weekday(@TexttoTime(x)); 7)<=1; x; "")
);
@Trim(wdlist)

But you could also have a look at the @BusinessDays  function...
makuletskiAuthor Commented:
this is the code i used in exploding the dates

@Explode(@TextToTime(@Text(@Date(start_date))+"-"+@Text(@Date(end_date))))

but when i added the code you gave, nothing was displayed

(i use this in a view)

what's wrong with my code?

(start_date and end_date are both time/date values)
Sjef BosmanGroupware ConsultantCommented:
So you have:

list:= @Explode(@TextToTime(@Text(@Date(start_date))+"-"+@Text(@Date(end_date))));
dlist:= @Text(list);
wdlist:= @Transform(dlist; "x";
   @If(@Modulo(@Weekday(@TexttoTime(x)); 7)<=1; x; "")
);
@Trim(wdlist)

The result here is a text list. If you want a date list, the last line in the formula should read
@TextToTime(@Trim(wdlist))

If need be, for debugging, add some @Prompt-statements here and there in the code, like the next line just after setting the variable list:
@Prompt([Ok]; "list"; @Implode(@Text(list); ", "))
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

makuletskiAuthor Commented:
dlist contains values but if i add the wdlist code...still..nothing is displayed...what could be wrong?
Sjef BosmanGroupware ConsultantCommented:
There's one serious error in the formula, but you could have found that while testing in a separate field (as I just did). This one provides the working days correctly:

start_date:= [1-1-2008];
end_date:= [2-2-2008];

list:= @Explode(@TextToTime(@Text(@Date(start_date))+"-"+@Text(@Date(end_date))));
dlist:= @Text(list);
wdlist:= @Transform(dlist; "x";
   @If(@Modulo(@Weekday(@TexttoTime(x)); 7)<=1; ""; x)
);
@Trim(wdlist)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
makuletskiAuthor Commented:
did not have access to add field to the form. can only work with the documents in a view, but not on the form. was able to test the latest code you gave. it worked perfectly. also saw the error you mentioned. thanks a lot!
Sjef BosmanGroupware ConsultantCommented:
Thanks for the compliment! I have a junkyard.nsf database where I test everything, there are heaps of old code in it and a lot of forms. Create one, even on Local, it'll help you!!

By the way, did you have a look at @BusinessDays?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.