Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Dates
Hi,
How can i check that the date is sunday and it is the 2nd week sunday of the month in VBA? thanks. regards, John |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Dates
Check out:
http://cpearson.com/excel/DateTimeVBA.htm#NDow In article , "John" wrote: How can i check that the date is sunday and it is the 2nd week sunday of the month in VBA? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Dates
If Weekday(TheDate) = 1 Then
'it's a Sunday D = Day(TheDate) If D = 8 And D <= 14 Then 'it is the 2nd Sunday The 1st Sunday must occur between the 1st and 7th of the month, the 2nd between the 8th and 14th, 3rd between the 15th and 21st, 4th between the 22nd and 28th, 5th between the 29th and end of month. The formula to determine which it is, is D = Day(TheDate) WhichOne = ((D - 1) \ 7) + 1 so the above could be generalized so you could specify which day of the week and which one: WhichDay = vbSunday WhichOne = 2 If Weekday(TheDate) = WhichDay Then 'the right day of the week D = Day(TheDate) If ((D - 1) \ 7) + 1 = WhichOne Then On Sun, 12 Sep 2004 23:12:17 -0700, "John" wrote: Hi, How can i check that the date is sunday and it is the 2nd week sunday of the month in VBA? thanks. regards, John |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Check if date is between two dates, then sum only those rows | Excel Worksheet Functions | |||
Error Check Dates | Excel Discussion (Misc queries) | |||
How can I check whether a column of dates are all before today's d | Excel Worksheet Functions | |||
How can I check whether a column of dates are all before today's d | Excel Worksheet Functions | |||
How to check for duplicates in a list of names and dates | Excel Discussion (Misc queries) |