# Thread: Ignore Sun and Sat in DateDiff

1. Registered User
Join Date
Oct 2003
Posts
1

## Unanswered: Ignore Sun and Sat in DateDiff

I'm using DateDiff("d", firstdate, now) but I want it to ignore Saturdays and Sundays.

any ideas?

2. Registered User
Join Date
Oct 2003
Location
Manchester, England
Posts
1
For every 7 days in the date difference you could minus 2 days. It would not be completely accurate but it would be close.

3. Registered User
Join Date
Jan 2002
Location
Bay Area
Posts
513
I found that this works in counting full days between a date and today:

Dim MyDate, TempDate As Date
Dim i, j, days As Integer

MyDate = "09/01/2003"
TempDate = MyDate
i = DateDiff("d", MyDate, Now)
i = Abs(i)
days = 0

For j = 1 To i
TempDate = TempDate + 1
If Weekday(TempDate) <> 1 And Weekday(TempDate) <> 7 Then days = days + 1
Next j

MsgBox "There are " & CStr(days) & " full days between " & _
MyDate & " and today, not counting Saturdays and Sundays"

You can add 1 to the results if you want to include today in the count.
The Weekday() function returns 1 for Sunday and 7 for Saturday.
Good Luck!
Jerry

4. Registered User
Join Date
Oct 2003
Location
Roanoke, Va
Posts
445

## Re: Ignore Sun and Sat in DateDiff

Originally posted by DavidHassid
I'm using DateDiff("d", firstdate, now) but I want it to ignore Saturdays and Sundays.

any ideas?
I tried this last night and it worked fine. I wrote a custom function that

determined the difference between the first and last day entered. It then

used this number to loop through the days one by one. Using the

Weekday built in date function I ignored Saturday and Sunday and

incremented an integer for the other days. Ex. If Weekday(NewDate)

<> 1 And Weekday(NewDate) <> 6 Then intDateCount = intDateCount

+ 1.

Hope this helps.

Gregg

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•