Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Leap-Year Problem


Message #1 by "Paul Price" <pprice@o...> on Tue, 18 Feb 2003 18:55:07
How do you get around the leap-year issue when selecting a rang of dates 
as in my code below. If you enter "2/29" it will error out.

<%
If VarMonth = "February" Then
FromDate = "2/1/" & VarYear
ToDate = "2/28/" & VarYear

Else
VarMonth = Request("SelectMonth")
VarYear = Request("SelectYear")
FromDate = Request("FromDate")
ToDate = Request("ToDate")

End IF
%>
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 19 Feb 2003 13:23:32 +1100
What are you trying to accomplish? I can't tell you "how to get around"
something if I don't know what you want to do.

If you just want to select everything in February then you could do:

(assuming StartDate = 2003/02/01 - 1st Feb

WHERE dateField >= StartDate
AND dateField < DateAdd("m", 1, StartDate)

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Paul Price" <pprice@o...>
Subject: [access_asp] Leap-Year Problem


: How do you get around the leap-year issue when selecting a rang of dates
: as in my code below. If you enter "2/29" it will error out.
:
: <%
: If VarMonth = "February" Then
: FromDate = "2/1/" & VarYear
: ToDate = "2/28/" & VarYear
:
: Else
: VarMonth = Request("SelectMonth")
: VarYear = Request("SelectYear")
: FromDate = Request("FromDate")
: ToDate = Request("ToDate")
:
: End IF
: %>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index