ASP statistical Information Implementation code/article daily, weekly, monthly, total access to the method _ Application skills

Source: Internet
Author: User
Tags current time
Copy Code code as follows:

<%
'//hittime Date: Get last access time
'//hits Digital: Get the total amount of browsing
'//hitsday Digital: Get today's browsing volume
'//hitsweeks digital: Get this week's browsing volume
'//hitmonths Digital: Get the volume of this month's browsing
' Database, add these 5 fields.
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 last access time
Dim Daynow,monthnow,weeknow
Daynow = Day (date ()) ' What's the date
Monthnow = month (date ()) ' Now a few months
Weeknow = Weekday (date ()) ' Now the day of the week 0 for Sunday
Rs1 ("hits") = Rs1 ("hits") + 1 ' total browse times + 1

If DateDiff ("D", hittime,now ()) = 0 Then ' compare last accessed date with current time days
Rs1 ("hitsday") = Rs1 ("hitsday") + 1 ' Today's Browse amount + 1
Else
Rs1 ("hitsday") = 1 ' Today's browse amount = 1
End If

If Monthnow = month (hittime) then
Rs1 ("hitmonths") = Rs1 ("hitmonths") + 1 ' This month's browse volume + 1
Else
Rs1 ("hitmonths") = 1 ' This month's browse volume + 1
End If

If DateDiff ("D", Hittime,now ()) > 6 Then ' has a problem with the period of the week, if the previous time is Friday, the next visit is Tuesday of next week, and the record is superimposed.
Rs1 ("hitsweeks") = 1
Else
If Weeknow <> 1 Then
Rs1 ("hitsweeks") = Rs1 ("Hitsweeks") + 1
Else
WEEKNOWSS = Weekday (Hittime) ' Week of last visit
If Weeknow = Weeknowss Then
Rs1 ("hitsweeks") = Rs1 ("Hitsweeks") + 1
Else
Rs1 ("hitsweeks") = 1
End If
End If
End If

Rs1 ("hittime") = Now () ' Update last interview
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/>
Week Visits: <%=rs1 ("Hitsweeks")%><br/>
Month Traffic: <%=rs1 ("hitmonths")%><br/>
<%
End If
Rs1.close
Set rs1=nothing
%>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.