I needed these, so I guess that you might too.. Use the calendar to choose a weekday (& also to check the answers). Choose the nth occurrence for that day in the month & click GO. The way the form is set up it gives you little practical utility, but if you need a way to set up a year's calendar (e.g. with holidays on the 1st Monday of August) or a recurrent meeting (e.g. on the 3rd Thursday of the month) then you might just find these helpful. Erel, I can't see the DayNumber() within the native functions, although "DayName" is there.
You could use the following sub to get the number of the day (1 - Sunday...): Code: Sub DayNumber(ticks) Return (Int(ticks/cTicksPerDay)) Mod 7 + 2End Sub
Amazing how you always have a better answer Consider my version to be a demonstration of how to do the same job in a more generic (complicated) fashion. Oh, for the record, the nthDay sub needs 0=Sunday, 1=Monday etc.
Week Number Hi Is there an easier way to calculate the: (1) Week number of the Year? (2) number of days between two given dates? Thanks!
Week Number Hi All, I did a search and found some codes and converted them to Basic4PPC format. It's based on the European/ISO standard... Though below sub is to get the weeknum... variable 'd' is also the day of the week which of course is redundant since Basic4PPC already has similar function. Hope the 'WeekNum' sub helps... Rgds WZSun ================================ Sub WeekNumber(yr,mh,dy) 'http://www.tondering.dk/claus/cal/node8.html If mh < 3 Then 'for dates in months of Jan/Feb a = yr - 1 b = Int(a/4) - Int(a/100) + Int(a/400) c = Int((a-1)/4) - Int((a-1)/100) + Int((a-1)/400) s = b-c e = 0 f = dy - 1 + 31 * (mh-1) Else ' for dates in March - December a = yr b = Int(a/4) - Int(a/100) + Int(a/400) c = Int((a-1)/4) - Int((a-1)/100) + Int((a-1)/400) s = b-c e = s + 1 f = dy + ((153 * (mh-3)+2)/5) + 58 + s End If g = Int((a+b)) Mod 7 If g = 0 Then g = 7 d = Int((f + g - e)) Mod 7 If d = 0 Then d = 7 n = f + 3-d If n < 0 Then i = 53 - Int((g-s)/5) Else If n > 364 + s Then i = 1 Else i = Int(n/7)+1 End If 'Note: d = day of the week '0=monday, 1 - tuesday Return i End Sub