jadams0173
Technical User
- Feb 18, 2005
- 1,210
I'm trying to take the weekends out from a date range. What I'm doing is letting the user look forward or backward any number days, months or years and tell them how many days there are with and without weekends.
It's part of a planning tool that I've been trying to build so we can get a ball park of how much money we do pay and wouldn't pay in OT if we could do a better job of planning.
Is there a mathmatical way to figure out how many weekend days there are and exclude them regardless of what the day is?
I'd perfer not to use a loop if at all possible.
So far I have:
It's part of a planning tool that I've been trying to build so we can get a ball park of how much money we do pay and wouldn't pay in OT if we could do a better job of planning.
Is there a mathmatical way to figure out how many weekend days there are and exclude them regardless of what the day is?
I'd perfer not to use a loop if at all possible.
So far I have:
Code:
Dim TotalDays As Double
'this should be the days with the weekends
TotalDays = CInt(txtDays.Text)
TotalDays += CInt(txtMonths.Text) * 30.4 '365/12 assume 30.4 days for month
TotalDays += CInt(txtYears.Text) * 365 '365 days per year
'this is the new date based on the user input
TodaysDate = TodaysDate.AddDays(CDbl(txtDays.Text))
TodaysDate = TodaysDate.AddMonths(CInt(txtMonths.Text))
TodaysDate = TodaysDate.AddYears(CInt(txtYears.Text))
Public Class Form1
Dim dte As Date
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dte = Now
lblTodaysDate.Text = dte.ToString("D")
End Sub