ASP statistical information/methods of article daily, weekly, monthly, and total visits, friends in need can refer to it. Copy the code code as follows:
<%
'//hittime date type: get the last access time
'//hits numeric type: get total page views
'//hitsday numeric type: get the number of views today
'//hitsweeks numeric type: get the number of views this week
'//hitmonths numeric type: get the number of views this month
'Add these 5 fields to the database.
set rs1=server.CreateObject(adodb.recordset)
rs1.open select * from qwbmnewssss where id=26,conn,1,3
if rs1.eof and rs1.bof then
response.write erry
else
hittime = rs1(hittime) 'Get the last access time
dim dayNow,monthNow,weeknow
dayNow = day(date()) 'What day is it now?
monthNow = month(date()) 'What month is it now?
weekNow = weekday(date()) 'The current day of the week 0 is Sunday
rs1(hits) = rs1(hits) + 1 'Total number of views + 1
if datediff(d,hittime,now()) = 0 then 'Compare the last access date with the current time and number of days
rs1(hitsday) = rs1(hitsday) + 1 'Today's views + 1
else
rs1(hitsday) = 1 'Today's views = 1
end if
if monthNow = month(hittime) then
rs1(hitmonths) = rs1(hitmonths) + 1 'Views this month + 1
else
rs1(hitmonths) = 1 'Views this month + 1
end if
if datediff(d,hittime,now()) > 6 then 'There is a problem when processing the period of the week. If the previous time is Friday and the next access is Tuesday of the next week, the records will still be superimposed.
rs1(hitsweeks) = 1
else
if weekNow <> 1 then
rs1(hitsweeks) = rs1(hitsweeks) + 1
else
weekNowss = weekday(hittime) 'The day of the week last visited
if weekNow = weekNowss then
rs1(hitsweeks) = rs1(hitsweeks) + 1
else
rs1(hitsweeks) = 1
end if
end if
end if
rs1(hittime) = now() 'Update the last visit question
rs1.update
%>
Time comparison: <%=datediff(d,hittime,now())%><br />
Current time: <%=now()%><br />
Last click time: <%=hittime%><br />
Current day: <%=dayNow%><br />
Current month: <%=monthNow%><br />
Current week: <%=weekNow%><br />
Total views: <%=rs1(hits)%><br />
Today’s visits: <%=rs1(hitsday)%><br />
Weekly visits: <%=rs1(hitsweeks)%><br />
Number of visits this month: <%=rs1(hitmonths)%><br />
<%
end if
rs1.close
set rs1=nothing
%>