PC Review


Reply
Thread Tools Rate Thread

DATEADD should skip the weekends

 
 
Eric
Guest
Posts: n/a
 
      3rd Jun 2009
Is there any easy within an append query to use the dateadd function that
will skip the weekends. I have this in my query;

nolaterthan: dateadd("d", 10, Date())

In my application nolaterthan is used for my memo's to sections where it
mentions that the memo has to be signed and returned no later than the date
stored in 'nolaterthan'. But the thing is that the dateadd should skip the
weekends so that it does not show any dates on saturdays or sundays. Is there
way to accomplish that?

Many thanks.
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      3rd Jun 2009
Take a look in the Date/Time section of "The Access Web"
http://www.mvps.org/access

There are a couple of options there.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Eric" <(E-Mail Removed)> wrote in message
news:9D6FC31F-E991-4546-B63A-(E-Mail Removed)...
> Is there any easy within an append query to use the dateadd function that
> will skip the weekends. I have this in my query;
>
> nolaterthan: dateadd("d", 10, Date())
>
> In my application nolaterthan is used for my memo's to sections where it
> mentions that the memo has to be signed and returned no later than the
> date
> stored in 'nolaterthan'. But the thing is that the dateadd should skip the
> weekends so that it does not show any dates on saturdays or sundays. Is
> there
> way to accomplish that?
>
> Many thanks.



 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      3rd Jun 2009
Many thanks I appreciate this very much, I have found the solution by using
these functions:

************* Code Start *************
Public Function HowManyWD(FromDate As Date, _
ToDate As Date, _
WD As Long)
' No error handling actually supplied
HowManyWD = DateDiff("ww", FromDate, ToDate, WD) _
- Int(WD = WeekDay(FromDate))
End Function
'************* Code End *************

In the same way, someone can easily get the number of weekdays
(excluding weekends) by subtracting number of Sundays and Saturdays:

'************* Code Start *************
Public Function HowManyWeekDay(FromDate As Date, _
ToDate As Date, _
Optional ToDateIsIncluded As Boolean = True)

HowManyWeekDay = DateDiff("d", FromDate, ToDate) - _
ToDateIsIncluded - _
HowManyWD(FromDate, ToDate, vbSunday) - _
HowManyWD(FromDate, ToDate, vbSaturday)
End Function
'************* Code End *************

"Douglas J. Steele" wrote:

> Take a look in the Date/Time section of "The Access Web"
> http://www.mvps.org/access
>
> There are a couple of options there.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Eric" <(E-Mail Removed)> wrote in message
> news:9D6FC31F-E991-4546-B63A-(E-Mail Removed)...
> > Is there any easy within an append query to use the dateadd function that
> > will skip the weekends. I have this in my query;
> >
> > nolaterthan: dateadd("d", 10, Date())
> >
> > In my application nolaterthan is used for my memo's to sections where it
> > mentions that the memo has to be signed and returned no later than the
> > date
> > stored in 'nolaterthan'. But the thing is that the dateadd should skip the
> > weekends so that it does not show any dates on saturdays or sundays. Is
> > there
> > way to accomplish that?
> >
> > Many thanks.

>
>
>

 
Reply With Quote
 
WireGuy
Guest
Posts: n/a
 
      31st Jul 2009
Do you need to set up a table with a date & day of week fields? How do you
run this procedure? On Open of a form or???

Thanks,
John

"Eric" wrote:

> Many thanks I appreciate this very much, I have found the solution by using
> these functions:
>
> ************* Code Start *************
> Public Function HowManyWD(FromDate As Date, _
> ToDate As Date, _
> WD As Long)
> ' No error handling actually supplied
> HowManyWD = DateDiff("ww", FromDate, ToDate, WD) _
> - Int(WD = WeekDay(FromDate))
> End Function
> '************* Code End *************
>
> In the same way, someone can easily get the number of weekdays
> (excluding weekends) by subtracting number of Sundays and Saturdays:
>
> '************* Code Start *************
> Public Function HowManyWeekDay(FromDate As Date, _
> ToDate As Date, _
> Optional ToDateIsIncluded As Boolean = True)
>
> HowManyWeekDay = DateDiff("d", FromDate, ToDate) - _
> ToDateIsIncluded - _
> HowManyWD(FromDate, ToDate, vbSunday) - _
> HowManyWD(FromDate, ToDate, vbSaturday)
> End Function
> '************* Code End *************
>
> "Douglas J. Steele" wrote:
>
> > Take a look in the Date/Time section of "The Access Web"
> > http://www.mvps.org/access
> >
> > There are a couple of options there.
> >
> > --
> > Doug Steele, Microsoft Access MVP
> > http://I.Am/DougSteele
> > (no e-mails, please!)
> >
> >
> > "Eric" <(E-Mail Removed)> wrote in message
> > news:9D6FC31F-E991-4546-B63A-(E-Mail Removed)...
> > > Is there any easy within an append query to use the dateadd function that
> > > will skip the weekends. I have this in my query;
> > >
> > > nolaterthan: dateadd("d", 10, Date())
> > >
> > > In my application nolaterthan is used for my memo's to sections where it
> > > mentions that the memo has to be signed and returned no later than the
> > > date
> > > stored in 'nolaterthan'. But the thing is that the dateadd should skip the
> > > weekends so that it does not show any dates on saturdays or sundays. Is
> > > there
> > > way to accomplish that?
> > >
> > > Many thanks.

> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Skip weekends rhhince Microsoft Excel Worksheet Functions 1 12th Oct 2009 12:12 AM
Re: DateAdd query expression to exclude weekends Douglas J. Steele Microsoft Access 2 26th Aug 2009 10:17 PM
Re: DateAdd (excluding weekends) depending on criteria in another field Tom van Stiphout Microsoft Access Form Coding 4 20th Mar 2009 09:28 PM
Skip Weekends in date Nigel Microsoft Excel Worksheet Functions 11 21st Dec 2007 10:47 AM
skip weekends and holidays =?Utf-8?B?U2hlcnls?= Microsoft Access VBA Modules 1 5th Jan 2005 12:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:49 AM.