Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Next week start end dates? 2

Status
Not open for further replies.

kovas

Technical User
Aug 6, 2002
88
US
How would I go about getting the next week start and end date?

I have a grid with mon-friday/hours, and want to load into a combo box week start date and end date. (12/9/2002 - 12/13/2002) and then switch between grid views on the combo box week selection.

So is there an easy way to do this?

thanks

 

'Try this

Dim temp As Date
temp = Date + 7
Do Until Weekday(temp, vbSunday) = 2
temp = temp - 1
Loop
MsgBox "Beginning of Next week is: " & temp
MsgBox "End of Next week is: " & temp + 4
 
Dim dtStart As Date
Dim dtEnd As Date

dtStart = (Date + 7)
dtStart = dtStart - (WeekdaydtStart , vbsunday) - 1)
dtEnd = dtStart + 6 [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
A, perhaps, overly generalized method:

Code:
Public Function basNxtWkDay(Optional DayOfWeek As Integer = vbSunday) As Date

    'Michael Red    12/14/2002 Tek-tips thread222-427748

    '? basNxtWkDay
    '12/15/02

    '? basNxtWkDay(vbFriday)
    '12/20/02

    Dim dtStrt  As Date

    dtStrt = (Date + 7)
    dtStrt = dtStart - (Weekday(dtStrt, DayOfWeek) - 1)

    basNxtWkDay = dtStrt

End Function

Of course, you would (except) for Sunday, need to supply the 'name' of week day date you desired, as in hte second example.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 

>A, perhaps, overly generalized method:
I don't think so...

I have a similar function that returns an array of the dates from the previous week.

One suggestion:

Public Function basNxtWkDay(Optional FirstDayOfWeek As VbDayOfWeek= vbSunday) As Date

That will produce of list of the possible days for the first day of the week.
[/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top