...

View Full Version : weekend and public holiday calculation

cloudy
05-30-2007, 02:15 AM
hi all,

is me again. now i have another probelem deal with the date.
i have to textbox to let the user insert the start date and end date and then one checkbox to let the user checked whether they wan to apply the half day leave or not.
after user click submit button, it will calculate the total leave at the backend, then dispaly the applicaiton information again before insert into the DB.
i will prepare another module to let the admin add on when is the public holiday.
the question is:
how can i retrieve the date from the start and end date from the user input and then compare with the weekend and public holiday.
if the date they applied involve the weekend(saturday and sunday) or public holiday, then the total leave they apply will reduce due to the not working day.
do u all have any idea?can guide me more.
i feel guilty to bring u all alot of problems as i m a beginner of ASP and also jz learn how to do a system..

hope to hear from u soon.
thank you.:)

Daemonspyre
05-30-2007, 01:50 PM
Without seeing your application (or an example of your application/what you are trying to accomplish), I can only offer suggestions. However, ASP can do the following:

1) We can calculate if the day is a Weekend day using 2 different functions, Weekday(date) and WeekdayName(date). Weekday returns an integer value relating to the day of the week. WeekdayName returns in short or long format the name of the day.

2) As to the Public Holiday additions: You know what the public holidays will be AND assuming that you have 8 hour work days, all you need to do is a simple comparison of the startdate, enddate, and holiday:

dHoliday = DateValue(holiday) 'make sure the information is in date format
dStartDate = DateValue(startdate) 'make sure the information is in date format
dEndDate = DateValue(enddate) 'make sure the information is in date format
'
If dHoliday >= dStartDate <= dEndDate then
hoursWorked = cInt(hoursWorked)-8
End If

Explanation:

DateValue() puts a value into a date. This is one way to make sure that the date is valid. You can also use IsDate().

The If...End If statement says If the date of the holiday is between the start date and the end date, then remove 8 hours from your [convert-to-Integer (cInt)] number of hours worked.

THIS IS NOT TESTED AND MAY NEED SOME TWEAKING BASED ON YOUR APPLICATION.

However, it is a starting point.

HTH!

cloudy
06-01-2007, 06:57 AM
hi, thanx for ur kind response.
i have solve it.
thank you very much!