Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 29th, 2008, 12:05 PM
Authorized User
 
Join Date: Feb 2007
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default DateDiff excluding weekend days

I would like to calculate the days between two dates and exclude the weekend days within a report. In the report I have datReviewStart and datFWComplete. I have another unbound txt box called txtDays. Using the datediff function, =datediff("d", [datReviewStart], [datFWComplete]) includes weekend days.

So, if my beginning date was 2/12/08 and the end date was 2/20/08, the result would be 8 days. I need the result to read 6 days (excluding Saturday and Sunday.) Any suggestions?

 
Old March 3rd, 2008, 09:48 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This is the rough way to make this calculation:

Dim dtDate As Date
Dim iWeekDays As Integer

dtDate = #01/01/2008#

iWeekDays = DateDiff("d", dtDate, Now()) * 5 / 7

Result: 44 as of March 3, 2008.

The real answer should be 45, but the end of the day today has not passed, so the answer is 44, the number of workdays that have actually passed since 1/1/2008.

If this is sufficient, then use this. Otherwise you can either loop through the dates and throw out 1's and 7's, or you can add one to add today's weekday IF it does not equal 1 or 7.

Did that help?


mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excluding certain records from a search RussLewis XSLT 5 March 4th, 2008 12:14 PM
Need answer by this weekend if possible Michele_Haywood Access VBA 5 November 22nd, 2006 05:57 AM
Need help by this weekend Help-Help-Help Michele_Haywood Access VBA 0 October 27th, 2006 11:37 AM
DateDiff calculation for Years, Months & Days demivolt ASP.NET 1.0 and 1.1 Professional 6 October 14th, 2006 12:14 AM
Excluding Rows fs22 SQL Language 2 August 17th, 2005 12:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.