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

Work Days

Status
Not open for further replies.

sammybee

Programmer
Sep 24, 2003
103
GB
Hi All,

I want a formula which will be datefield - datefield - workdays - any ideas?

Cheers

Sam
 
Hi Steve,

Cheers for your help, I had looked at the link before but working for a computer with no ability to download or unzip. The only script I can try is the following:-


Datevar FirstDay:= Date({APPLIC_LIST_ENTRIES.ALE_STATUS_START});
datevar LastDay := Date({APPLIC_LIST_ENTRIES.ALE_STATUS_END});
numbervar Days;
numbervar Weekends;
numbervar Finaldays;
DateVar StartDate;
Datevar EndDate;
if firstday <=Date(0,0,0) or LastDay <=Date (0,0,0) then
finaldays := 0
else
(if dayofweek(FirstDay) = 7 then
startdate:= FirstDay +1
Else
Startdate := FirstDay;

If dayofweek (lastday) = 7 then
enddate:=LastDay +2
Else if dayofweek (lastDay) = 1 then
enddate := LastDay + 1
Else
EndDate := LastDay;

Days := (endDate - StartDate) +1;

if Days >=7 then
Weekends := (Round((Days/7),0))*2
else if dayofweek(startdate) > dayofweek(enddate) then
weekends := 2
else
weekends := 0;

Finaldays := Days-Weekends;

If dayofweek (lastday) = 7 then finaldays:= finaldays -1;
if dayofweek(lastday) = 1 then finaldays:=finaldays - 2;
);
finaldays;

When I try testing this I get the error 'The result of selection formula must be Boolean.

Also my 2 date fields are datetime, what is the correct conversion for this! Any help appreciated!

Many thanks

Sam



 
Sam,

The above formula needs to be placed in an actual formula and not in the select expert. This is why you will be receiving the error 'The result of selection formula must be Boolean'.

There are a couple of ways which you can convert a date, i'd try changing the DateVar to be DateTimeVar and any 'date()' to a datetime().

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top