Days added to date (1 Viewer)

commandolomo

Registered User.
Local time
Today, 15:07
Joined
Jun 11, 2004
Messages
73
Hi one and all

I am basically trying to do what another member has detailed in this thread

http://www.access-programmers.co.uk/forums/showthread.php?t=77802&highlight=add+days

where someone has suggested another link

http://www.access-programmers.co.uk/forums/showthread.php?t=62570

which the person states has solved the problem - however it seems this link is dead, perhaps as a result of the site hack.

I am sure you can see my question coming like a rabbit in headlights - does anyone know how to do this?!?

Basically, I want to add a certain number of days (as specified in a text box-(txtDaysToAdd)) to a date, where weekends and self defined holidays are excluded (I have already set up my tbleHolidays to enter such dates).

Any ideas?

Thanks in advance
 
Last edited:

Bat17

Registered User.
Local time
Today, 15:07
Joined
Sep 24, 2004
Messages
1,687
see if this does what you want
Code:
Function GetDueDate(ByVal dStartDate As Date, intDaysToAdd As Integer) As Date
'Add days
Do While intDaysToAdd > 0
    dStartDate = dStartDate + 1
    If Weekday(dStartDate, vbSunday) = 1 Or Weekday(dStartDate, vbSunday) = 7 Then
        dStartDate = dStartDate + 1
    ElseIf DCount("dHolidaydate", "tblHolidays", "dHolidaydate = #" & dStartDate & "#") Then
        dStartDate = dStartDate + 1
    Else
        intDaysToAdd = intDaysToAdd - 1
    End If
Loop
 GetDueDate = dStartDate
End Function

Peter
 

commandolomo

Registered User.
Local time
Today, 15:07
Joined
Jun 11, 2004
Messages
73
Nice one, thanks for the reply. Would I put this in a module, then call it from the form? If so, which part of the function identifies the number of days I want to add?

Cheers
:)
 

Bat17

Registered User.
Local time
Today, 15:07
Joined
Sep 24, 2004
Messages
1,687
Yes put it in a module

dStartDate = start date
intDaysToAdd = Days to add to start date

There is no error checking though to make sure you pass it valid data.

Peter
 

Users who are viewing this thread

Top Bottom