View Single Post
  #7  
Old April 15th, 2010, 12:41 AM posted to microsoft.public.access.gettingstarted
John... Visio MVP
external usenet poster
 
Posts: 900
Default Help with Function: date range

"John W. Vinson" wrote in message
...
On Wed, 14 Apr 2010 12:47:24 -0600, "Bre-x" wrote:

Public Function my_dates(the_date As Date) As Integer

Select Case the_date

Case #7/31/2005# To #8/1/2006#
my_dates = 2006
Case #7/31/2006# To #8/1/2007#
my_dates = 2007
Case #7/31/2007# To #8/1/2008#
my_dates = 2008
Case #7/31/2008# To #8/1/2009#
my_dates = 2009
Case #7/31/2009# To #8/1/2010#
my_dates = 2009
Case Else
my_date = 0
End Select
End Function

Thank you!!!


Public Function My_Dates(the_date As Date) As Integer
My_Dates = Year(DateAdd("m", 5, the_date)
End Function

will work in any year (even leap years). And it's one line.
--

John W. Vinson [MVP]



A lot more elegant than my solution. You only have to know the number of
months left in the year rather than the number of days left in the year.

John... Visio MVP