A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

I hate date math!



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3  
Old January 14th 06, 12:11 PM posted to microsoft.public.outlook.program_vba
Michael Bednarek
external usenet poster
 
Posts: 28
Default I hate date math!

On Thu, 12 Jan 2006 18:23:08 -0700, Steve Roberts wrote in
microsoft.public.outlook.program_vba:

I have a custom .oft form for vacations that I am trying to clculate the
number of business days the person will be gone.
This is my current formula that returns the total number of day fine but
does not exclude the weekends.DateDiff("d",[StartDate],[EndDate]) + 1

Can someone point me in the right direction please.


Calculate the absolute week number in VBA's idea of a calendar for both
dates, subtract one from the other, multiply by 2 for weekends, subtract
that from DateDiff.

DateDiff("d", datStart, datEnd) + 1 _
- ((datEnd - Weekday(datEnd, vbMonday) - 1) / 7 _
- (datStart - Weekday(datStart, vbMonday) - 1) / 7) * 2

This doesn't account for public holidays. For that, you could use
Set myExcel = Application.CreateObject("Excel.Application")"
and use Networkdays() in a workbook which contains the holidays.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
why the date changes on 4 emails? Jack Outlook Express 9 March 9th 06 12:17 AM
I hate Outlook 2002. Can I go back to Outlook 2000? eppkai Outlook - Installation 4 February 12th 06 06:49 PM
go to date quicker yster Outlook - Calandaring 2 February 11th 06 09:58 PM
date fields - link the calander pop-up to a custom date field Tom Outlook - Using Forms 0 January 23rd 06 09:13 PM
Exporting Date received and Date Sent to Access Sugarthebeet Outlook - General Queries 1 January 19th 06 08:06 PM


All times are GMT +1. The time now is 05:01 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.