Hi guys,
please help me again in getting the result of Frist Monday,Tuesday, Wednesday, Thursday, Friday of the month
and i want also to get the date of every 15 and 30 of the month.
Please help.
Thanks.
Hi guys,
please help me again in getting the result of Frist Monday,Tuesday, Wednesday, Thursday, Friday of the month
and i want also to get the date of every 15 and 30 of the month.
Please help.
Thanks.
Here's a routine :
Public Function FirstMonday(TheDate)
Dim WhatDate As Date, DayNum As Integer
DayNum = 1
Do Until DayNum > 7
WhatDate = CDate(Format(TheDate, "mm") & "/" & DayNum & "/" & Format(TheDate, "yyyy"))
If DatePart("w", WhatDate) = 2 Then Exit Do
DayNum = DayNum + 1
Loop
FirstMonday = WhatDate
End Function
To use it in a query:
Mond:FirstMonday(datefieldname)
Tues:FirstMonday(datefieldname)+1
etc
for the 15th and 30th you would use :
CDate(Format(TheDate, "mm") & "/15/" & Format(TheDate, "yyyy"))
The format of the date is American - change it to your way if different.
@aytee111, thanks for your reply.
here's my scenario..
i have 20 different countries that has a lot of windows.
1st scenario:
US, every 15 and 30 of the month. if the date falls between 1 to 15 the date should be 15 and between 16 to 30 the date should be 30 and if the month has 31st it should be the next month which 15 in this scenario.
2nd scenario. some countries has every monday or tuesday etc etc...
if the date falls on tuesday to sunday it should be the next monday ... etc..
i hope you understand my explanation.
thanks again and more power to this forum.