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

weekday function

Status
Not open for further replies.

Ramlawati

Programmer
Jun 21, 2001
7
MY
Dear All,

I have a problem with my e-leave system. Let say i'm taking a leave on the 14th of November(Leaving) that is on Wednesday and will be returning on 19th of November (Returning) on Monday.. Suppose the duration of my leave is 3 days..but the system count 5 days including saturday and sunday.

This is a part of my coding :-

FIELD Leave_Duration := (@Date(Returning) - @Date(Leaving)) / 86400;


The problem is how to count the leave minus the weekend.

Any help will be appreciated.

TQ

 
Hi.

You could try building some extra coding using the @Weekday function.

Build a loop that checks every day that the person is away for and submit an @Weekday evaluation against that date. If the return value is either a 1 or 7 (Sunday and Saturday respectively), then don't add that day to the running total. This should give you a successful value.
 
Hi,

here's one I spent all last week on! I also have a field called 'hols' which does an @DbLoookup on a list of public holidays and deducts them as well.

Good luck,
DanT


holidays:= @Text(hols);
@Prompt([OK];"Hols"; @Implode(holidays;", "));

REM "Gets all the days between the start and end date";

alldays:= @Explode(@TextToTime(@Text(Start)+"-"+@Text(EndDate)));
@Prompt([OK];"All"; @Implode(alldays;", "));

REM "Removes those dates which are holidays";

workdays := @Trim(@Replace(alldays; holidays; ""));
@Prompt([OK];"Work"; @Implode(workdays;" , "));


tdays:= @Text(@Weekday(@TextToTime(workdays)));
@Elements(@Trim(@Replace(tdays; "1":"7";NULL)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top