Re: Two date pickers

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Rick Rothstein (rickNOSPAMnews_at_NOSPAMcomcast.net)
Date: 04/08/04


Date: Wed, 7 Apr 2004 23:17:18 -0400

1. You shouldn't have to worry about that. Dates are stored as Doubles; it
is only when you display them or assign them from Strings that regional
settings come into play. If you take the DatePicker's Value property and
assign it to a Date variable, VB should take care of the rest for you.

2. Take the dates from the DatePicker controls and assign them to Date
variables and then feed those Date variables into this function which will
return the number of workdays (not Saturday or Sunday) between two dates

Function WorkDays(StartDate As Date, EndDate As Date) As Long
  Dim NumWeeks As Long
  NumWeeks = (EndDate - StartDate) \ 7
  WorkDays = NumWeeks * 5
  For D = (StartDate + NumWeeks * 7) To EndDate
     If (Weekday(D) Mod 6) <> 1 Then WorkDays = WorkDays + 1
  Next D
End Function

You'll have to construct a separate function if you want to count the
holidays between the two dates.

Rick - MVP

"Chris" <chrispow88NOSPAM@hotmail.com> wrote in message
news:4074bd57$0$16572$5a62ac22@freenews.iinet.net.au...
> Hi,
>
> 1. Cannot use 'JUNE' etc for month name as this will vary.
> 2. I may need to let the user decide on what is a weekend Sat/Sun or
> Fri/Sat but as a first cut just assume Sat/Sun.
>
> That's all I was thinking.
>
> Thanks
>
> Chris
>
> "Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message
> news:uqoy%23ERHEHA.3576@TK2MSFTNGP10.phx.gbl...
> > > Can anyone suggest how to do the following:
> > >
> > > I have two date pickers dp1 and dp2 and I can find the numbers of days
> > > between them.
> > >
> > > So I can say Fred has been available for work from dp1 to dp2.
> > >
> > > But how do I work out how many weekends are in that range, so I can
> > remove
> > > them from the number of days worked, taking into account international
> > > variations?
> > >
> > > Has anyone got any sample code I can look at?
> >
> > What are the "international variations" that you want your code to take
> into
> > account?
> >
> > Rick - MVP
> >
> >
>
>



Relevant Pages

  • Re: performance monitoring configuration and errors.
    ... Partial Description: No strings to display. ... Status code returned is data DWORD 0. ... status code returned is the first DWORD in the attached data. ...
    (microsoft.public.win2000.general)
  • Re: [PATCH] String conversions for memory policy
    ... Changing one of the strings should not break the code until the ... Only after this checking can the resulting policy ... you show how to merge this display of mempolicy ... that other half should not also be used to display memory policies, ...
    (Linux-Kernel)
  • Re: performance monitoring configuration and errors.
    ... | Partial Description: No strings to display. ... Status code returned is data DWORD 0. ... | status code returned is the first DWORD in the attached data. ...
    (microsoft.public.win2000.general)
  • Re: performance monitoring configuration and errors.
    ... > | Partial Description: No strings to display. ... > * You may need to remove and reinstall IIS ... > | exception or returned an invalid status. ...
    (microsoft.public.win2000.general)
  • Re: RfD: XCHAR wordset (for UTF-8 and alike)
    ... > words work for strings that contain xchars. ... have to have the DCS up and running before you have a proper rich text ... display, and it is perfectly possibly that you run without every having ... the definition of XCHAR is: an extended DCS character set ...
    (comp.lang.forth)