Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Visual Basic (https://www.askmehelpdesk.com/forumdisplay.php?f=469)
-   -   Leave days (https://www.askmehelpdesk.com/showthread.php?t=324272)

  • Mar 3, 2009, 02:05 AM
    Mistery1
    Leave days
    Hi there,

    I need help with calculating leave days in vb.net. I need to calculate the total number of leave days taken, also leave days should not include and weekends and public holidays.
  • Mar 4, 2009, 06:01 AM
    Perito

    I think I'd like a bit more information.

    It's not difficult to calculate days between two dates. I'm sure I could look up an algorithm (I don't have one right off my head), but most of them use the concept of a "Julian date". Loosely, some date is given the date of zero. From then on, the date is subsequently increased for each successive day. (A purist's Julian date starts at January 1, 4713 BC, but we don't care about that). So, you figure out what beginning and ending dates you care about and subtract them. The difference is the number of days between them. If you want to include both end dates, you have to add a 1.

    After that, you need to figure out how many weekends and public holidays there are. For that, you need a list of public holidays (there is no universal list). You calculate the day of the week for the Julian Days at the beginning and ending of the period and from there you can figure out how many Saturdays and Sundays there are. From the list of holidays, you can subtract out those.

    If you wish to pursue this, I can look up an algorithm to calculate Julian days from some arbitrary date (not necessarily 4717 BC) and the days of the week.

  • All times are GMT -7. The time now is 03:58 PM.