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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi friends! how can i get the da 1

Status
Not open for further replies.

cuok

Programmer
Dec 24, 2001
201
Hi friends!

how can i get the date of next Momday from any day in this week ?

I need to get next Monday (by function, sql...) in TextBox every time i opens the form which contains in another TextBox the day of today (date() - short date).

if today date is 08/18/03 (it is Monday) i need to get 08/25/03
if today date is 08/19/03 i need to get 08/25/03
if today date is 08/20/03 i need to get 08/25/03
if today date is 08/21/03 i need to get 08/25/03
ETC'

thanks for any help

CUOK


 
The simple way to do it is create a vba function called nextmonday that accepts any date as a parameter and it would look something like this

function nextmonday(thedate as date) as date
dim i as integer
dim rollingdate as date

if weekday(thedate) = 2 then'2 is the number used for monday
nextmonday = thedate
exit function
end if

for i = 1 to 7
rollingdate = thedate + 1
if weekday(rollingdate) = 2 then
nextmonday = rollingdate
end if
next i

end function

I havent tested this but I am sure you will get the idea.

David
 
Public Function NextMonday(InDate As Date) As Date
NextMonday = DateAdd("d", 8 - DatePart("w", InDate, vbMonday), InDate)
End Function

 
Thanks a lot foreveryoung and Nirris68!

I ttried Norris68 function and it works great
later i try foreveryoung function

thanks again

CUOK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top