Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy weekend and public holiday calculation

    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.

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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.

    See here for more information:
    http://msdn.microsoft.com/library/de...a4421d18bf.asp

    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:

    Code:
    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!

  • #3
    New Coder
    Join Date
    May 2007
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi, thanx for ur kind response.
    i have solve it.
    thank you very much!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •