View Full Version : Time Periods


mugman17
07-25-2001, 08:09 AM
Is there a way to find out ,lets say ,how many Januarys have passed between two dates?

D-Fresh
07-26-2001, 06:05 AM
Well you could use the datediff and dateadd functions...

function NumJanuary(Date1 as date, Date2 as date) as integer

dim NumYears as integer
dim ctr as integer
dim JanuaryCount as integer

JanuaryCount = 0
NumYears = datediff("yyyy",Date1, Date2)

for ctr = 1 to NumYears
if month(dateadd("yyyy",ctr,Date1)) = 1 then
JanuaryCount = JanuaryCount + 1
endif
next ctr

NumJanuary = JanuaryCount

end function

Hope this function helps for you...

Doug

[This message has been edited by D-Fresh (edited 07-26-2001).]

[This message has been edited by D-Fresh (edited 07-26-2001).]