Calculate week ending date ....... 
Author Message
 Calculate week ending date .......

Hello again,

Quite  a while back I saw some code about calculating Weekending date based
on current date.  Not knowing what the Subject read I have not been
successful looking in DejaNews.

Without manually creating a table with startdate,enddate,weekendingdate,
how does one calculate this??

I am in Access97.  I want my queries to only show current week information.
 I know how to set the criteria, but not how to retrieve that calculated
weekendingdate.
--



Fri, 28 Jul 2000 03:00:00 GMT  
 Calculate week ending date .......

Alan:
give this a whirl.

Function GetWeekendDate(pvarDate as Variant) As Variant

If Not IsDate(pvarDate) Then
    GetWeekendDate = False
    Exit Function
End If

GetWeekendDate = DateAdd("w", 7 - WeekDay(pvarDate), pvarDate)

End Function

-jim

Quote:

> Hello again,

> Quite  a while back I saw some code about calculating Weekending date
> based
> on current date.  Not knowing what the Subject read I have not been
> successful looking in DejaNews.

> Without manually creating a table with
> startdate,enddate,weekendingdate,
> how does one calculate this??

> I am in Access97.  I want my queries to only show current week
> information.
>  I know how to set the criteria, but not how to retrieve that
> calculated
> weekendingdate.
> --




Fri, 28 Jul 2000 03:00:00 GMT  
 Calculate week ending date .......


Quote:
>Without manually creating a table with startdate,enddate,weekendingdate,
>how does one calculate this?? . . . . weekendingdate.

'---------------------------------------------------------------------------
---
Public Function GetLastDayOfWeek(ByVal dtDay As Date, _
Optional vbWeekStartsOnDay As Variant = vbUseSystemDayOfWeek) As Date
'Find the date of the last day in the current week

'. . Getz notes this algorithm relies on the fact that the
'. . Weekday function returns an integer.  In VBA, you can
'. . use dates interchangeably as both long numbers in math
'. . and as dates in date functions. Thus, let's
'. . use 11/6/97, a Thursday, as an example:
'   11/8/97 Sat  = 11/6/97 -  5 days [Thursday]              + 7
GetLastDayOfWeek = dtDay - WeekDay(dtDay, vbWeekStartsOnDay) + 7

End Function



Fri, 28 Jul 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Calculate Date Range From Prior Week

2. how to calculate dates for a given week?

3. Calculate date from week number in VB5.0

4. Beginning and ending dates of a specified week

5. Need VBA to calc week-ending date

6. calculate dates calculate time

7. Date / Same date or first day of week

8. Calculate week

9. Calculating the Week of the Year

10. Calculating Week of Year

11. Q:Calculate number of weeks!

12. Calculate Week of year ?

 

 
Powered by phpBB® Forum Software