'FromYear is the year entered by the user, extracted from the full date.
'if its not a leap year and the month is february and the user chooses the 29th of Feb the day must be overwritten with the 28th.
'if it is a leap year then it must start after the 23rd but end at 29
'Code*****

if (FromYear Mod 4 <> 0) and (FromYear Mod 100 <> 0) and (FromYear Mod 400 <>) then
if FromMonth = 2 then
if FromDay = 29 then
FromDay = 28
else FromDay = 29
end if
if FromDay > 22 then
ToDay = (FromDay + 6) - 28
ToMonth = FromMonth + 1
end if
end if
elseif FromDay > 23 and <29 then
ToDay = (FromDay + 6) - FromDay ToMonth = FromMonth + 1

I'm trying to help you out here but don't completely understand what you are trying to do. Could you post the entire question.
I get the first part where you are checking to see if it is a leap year and changing the 29th to the 28th if it is not a leap year. But I don't understand what exactly the last requirement is

hi there
thanks so much for replying.
i found a solution, but its not working a 100%
lets say the user enters 25Feb, the week must start from 25 feb and the next 7 days.
trick is that there are only 28 days in a non-leap year so it must jump from feb to 4 March. i'll show u the leap yr calc ok.

(the part that is commented out doesnt work)

if StrComp(TypeOfReport,"Weekly",0) = 0 then
FromMonth = CInt(request("datemonth"))
FromYear = CInt(request("dateyear"))
FromDay = CInt(request("dateday"))

ToYear = FromYear
ToMonth = FromMonth
ToDay = FromDay + 6

if FromDay = 0 then
FromDay = 1
end if

if FromMonth = 0 then
FromMonth = 1
FromDay = 1
ToDay = FromDay + 6
ToMonth = 1
ToYear = FromYear +1
end if

if ToMonth = 13 then
ToDay = FromDay + 6
ToMonth = 1
ToYear = FromYear + 1
end if

'if (FromYear Mod 4 <> 0) 'and (FromYear Mod 100 <> 0) and (FromYear Mod 400 <>) then
if FromMonth = 2 then
'if FromDay = 29 then
' FromDay = 28
' else FromDay = 29
'end if
if FromDay > 22 then
ToDay = (FromDay + 6) - 28
ToMonth = FromMonth + 1
end if
end if
'elseif FromDay > 23 then
' ToDay = (FromDay + 6) - FromDay
' ToMonth = FromMonth + 1

Thx
Addy

You seem to be making a lot of hard work for yourself when there are built in functions that will do all of the date calculation work for you. Look into using the DATEADD function, maybe coupled with DATEPART and then you just need to pass in valid dates, plus or minus any number of units of time measurement to get the required results.

A quick example:

<%
dim strMonth, strDay, strYear, strDate
strMonth = "2"
strDay = "23" 
strYear = "2004"
strDate = strMonth & "/" & strDay & "/" & strYear
response.write dateAdd("d", 7, strDate) ' will add 7 days to the supplied date and change days, months, years as required
%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.