Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  Answer this Question    Ask about Visual Basic    Ask about another Subject  
 

Mistery1
Mar 3, 2009, 01:05 AM
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.

Perito
Mar 4, 2009, 05:01 AM
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.