Iam having trouble in finding last weekend date using asp or asp.net
Iam using calender control to calculate the lastweekend date.I can use any process not only with calendar control..
please help in this issue..
This will work
<%
dim dtTmp, i
dtTmp = CDATE("5/31/2002" 'Last day of the month
for i = 0 to -7 step -1
if WeekDay(dateadd("d",i,dtTmp)) = 7 or
Weekday(dateadd("d",i,dtTmp)) = 1 then
dtTmp = dateadd("d",i,dtTmp)
Exit for
end if
next
Response.Write "Last Weekend day of the month is :" & FormatDateTime(dtTmp)
%>
Thanks for your guidence...I appreciate that
it works fine.. but the problem is when if I try to look for the last weekend in every month first date, its showing the same month, instead of previous month lastweekend date..
for example..if I want to see previous weekend date on 1st of june, it displays 6\1\2002 instead of 5/26/2002..
I think you understand it....Please can you suggest me in this scenario..
Just check the date first to see if it is the weekend.
and then back them out.
Select Case WeekDay(dtTmp)
Case 7 ' Saturday
dtTmp = DateAdd("d", -1,dtTmp)
case 1 'Sunday
dtTmp = DateAdd("d", -2,dtTmp)
end select
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.