|
-
Aug 23rd, 2001, 04:18 PM
#1
Thread Starter
PowerPoster
Date Back with WeekEnds (see code)
Looking for a better/easier routine tol generate a date back including weekends just using an ending date and the number of days back:
Currently using:
Function CalcBegDateTime(dtmLastDate As Date, iDaysBack As Integer) As Date
'Calc an estimated Beginning Date
Dim dtmEstBegDate As Date
Dim iNumWeekDays As Integer
Dim iTotWeekEndDays As Integer
'Get an approximate date from Days Back
dtmEstBegDate = DateAdd("d", -iDaysBack, dtmLastDate)
'Determine total weekend days, if > Week
If iDaysBack > 6 Then
'Next determine number weekdays in this period
iNumWeekDays = HowManyWeekDays(dtmEstBegDate, dtmLastDate) '<<<Function
iTotWeekEndDays = (iDaysBack - iNumWeekDays) * 2
'Subtract weekend days from EstBegDate to get a final begin date
dtmEstBegDate = DateAdd("d", -iTotWeekEndDays, dtmEstBegDate)
End If
'Add time and Return
CalcBegDateTime = CombineDateTime(dtmEstBegDate, #12:00:00 AM#) '<<<Function
End Function
Thanks
David
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|