...
My question is when the program query database, I need to know the beginning
date and ending date of that week.
<%
' strDate = RS("Date")
strDate = Date()
strWeekdayName = LCase(WeekdayName(weekday(strDate)))
Dim myDaysArray(7)
myDaysArray(0) = "monday"
myDaysArray(1) = "tuesday"
myDaysArray(2) = "wednesday"
myDaysArray(3) = "thursday"
myDaysArray(4) = "friday"
myDaysArray(5) = "saturday"
myDaysArray(6) = "sunday"
For intLoop = 0 To UBound(myDaysArray)
If strWeekdayName = myDaysArray(intLoop) Then
If intLoop = 0 Then
strStartOfWeekDate = strDate
strEndOfWeekDate = DateAdd("d", 6, strDate)
ElseIf intLoop = 6 Then
strStartOfWeekDate = DateAdd("d", -6, strDate)
strEndOfWeekDate = strDate
Else
strStartOfWeekDate = DateAdd("d", -intLoop , strDate)
strEndOfWeekDate = DateAdd("d", (6-intLoop), strDate)
End If
End If
Next
Response.Write "Current Date : " & strDate & "<br>"
Response.Write "Start Of Week Date : " & strStartOfWeekDate & "<br>"
Response.Write "End Of Week Date : " & strEndOfWeekDate & "<br>"
%>
If your 'week' doesn't start on a Monday, change the values in the array, ie
:
tueday
wednesday
thursday
friday
saturday
sunday
monday
Hope this helps, oh and if you run it as it is at the moment it should work
fine, commented line at the top for your date from the database etc, then
just remove the response.writes at the bottom.
Regards
Rob