Jane McCarty:
1) There is no single scripted command that will accept parameters for ...
From Date
To Date
Pointer to the Hours by DayOfWeek Table
Pointer to the Holidays Table
... but the extensible nature of ZOHO Creator allows for the development of a User Defined Function that can be invoked with a single command like ...
Hours = thisapp.GetElapsedHours(FromTime,ToTime);
And thanks to the ZOHO Marketplace and this Forum ... novice Users can request the development of this generic function ... and since the development cost can be shared by several users, the individual one time cost can be minimal.
2) ZOHO Creator has the native commands to ...
a) convert dates (in a variety of formats) to a numeric value representing "number of days since some fixed date in the past" (like December/31 1899)
b) get the DayOfWeek for a given date
c) lookup a record in a Table (for the Hours for a given DayOfWeek)
... so the process to accomplish the desired result does not require a high degree of difficulty ... a back of the envelope design would be something like ...
If FromDate is less than ToDate ... return an error
If FromDate is same as ToDate ... Hours = 0
If FromDate is greater than ToDate
For each day (currentDate) in range FromDate to ToDate
If currentDate is not a Holiday
Accumulate Hours for 'DayOfWeek corresponding to currentDate'
EndIf
EndFor
EndIf
Note: the For/EndFor loop is implemented by recursively calling a function that performs actions within the For/EndFor block
3) The only thing one needs to be cognizant of is that ZOHO Creator has a cap (of 5000 script commands) per User Action ... so if you needed to calculate the number of hours between dates that are (say) more than 100 days apart ... you might bump into this limit.
Gaev
Hi,
We have created a sample application that calculates total hours and End-date based on working hours and holiday information.
The holiday list is available here and Working hours list is available here .
Calculate End day form calculates end date based on working hours and holidays.
Calculate Total duration form calculates the total working hours between two dates factoring the holidays and working hours.
Click here to get the source code of the application to this forum.
Thanks,
Nandhini
Thanks everyone for efforts!
You can check out my review following this link:
http://webappsatwork.blogspot.com/2009/09/zoho-creator-write-program-to-calculate.html
Best regards,
Jane
