ASP implemented several methods to remind birthdays with code _ Application Tips

Source: Internet
Author: User
ASP Birthday Automatic Reminder program with ASP, debugging through, the use of convenient-asp birthday automatically remind small programs with the preparation of ASP, debug, easy to Use
method One:

Originally written on a class site for the last one months of the classmate Birthday reminder applet. Although not very good, and very messy, but at least it is their own thinking to think, so I value more. Although the ASP program has a lot to learn from others. But I think more of the time, we should be in the classic highlights, innovation that is not to keep the rules and not always can only be an ordinary programmer.

<%
Dim daydif
Dim days ' Define the number of dates before and after the birthday of the students, such as 60 of the one months before the first one months of the list of students.
Sql= "Select Name,brithday from class"
Set Rs=server. CreateObject ("ADODB.") RecordSet ")
Rs. Open sql,con,1,1
For I=1 to Rs.recordcount ' Read all the data
If Rs.eof then exit for
Daydif=abs (DateDiff ("D", Date,rs ("Birthday")) MoD 365
If Daydif < days
Response.Write rs ("name")%>
Response.Write "<font color=" #FF0000 ">"
Response.Write rs ("Birthday") & ", </font>"
End If
Rs.movenext
Loop
Rs. Close
Set rs=nothing
%>

Method Two:
<%
Days1=split (Date (), "-")
Days2=split (DATEADD ("D", 5,date ()), "-")
Sql= "SELECT [Id],memberid,birthday from Customers"
If DAYS1 (1) <>days2 (1) Then
Sql=sql+ "where" (month (Birthday) = ' "&days1 (1) &" ' or month (birthday) = ' "&days2 (1) &" ') "
Else
sql=sql+ "where month (birthday) = '" &days1 (1) & "'"
End If
Sql=sql+ "and day (birthday) between '" &days1 (2) & "' and" &days2 (2) & "'"
' Response.Write (SQL)
Set Conn=server. CreateObject ("Adodb.connection")
Conn.Open ConnStr
Set Rs=conn.execute (SQL)
If not rs.eof then%>
<script language= "JavaScript" >
Window.onload = getmsg;
Window.onresize = Resizediv;
Window.onerror = function () {}
SMS prompt use (Asilas added)
var divtop,divleft,divwidth,divheight,docheight,docwidth,objtimer,i = 0;
function getmsg ()
{
try{
Divtop = parseint (document.getElementById ("Emeng"). style.top,10)
Divleft = parseint (document.getElementById ("Emeng"). style.left,10)
Divheight = parseint (document.getElementById ("Emeng"). offsetheight,10)
Divwidth = parseint (document.getElementById ("Emeng"). offsetwidth,10)
Docwidth = Document.body.clientWidth;
Docheight = Document.body.clientHeight;
document.getElementById ("Emeng"). Style.top = parseint (document.body.scrolltop,10) + docheight + 10;//divHeight
document.getElementById ("Emeng"). Style.left = parseint (document.body.scrollleft,10) + docwidth-divwidth
document.getElementById ("Emeng"). style.visibility= "Visible"
Objtimer = Window.setinterval ("Movediv ()", 10)
}
catch (e) {}
}
function Resizediv ()
{
I+=1
if (i>500) Closediv ()
try{
Divheight = parseint (document.getElementById ("Emeng"). offsetheight,10)
Divwidth = parseint (document.getElementById ("Emeng"). offsetwidth,10)
Docwidth = Document.body.clientWidth;
Docheight = Document.body.clientHeight;
document.getElementById ("Emeng"). Style.top = Docheight-divheight + parseint (document.body.scrolltop,10)
document.getElementById ("Emeng"). Style.left = Docwidth-divwidth + parseint (document.body.scrollleft,10)
}
catch (e) {}
}
function Movediv ()
{
Try
{
if (parseint (document.getElementById ("Emeng"). style.top,10) <= (Docheight-divheight + parseint ( document.body.scrolltop,10)))
{
Window.clearinterval (Objtimer)
Objtimer = Window.setinterval ("Resizediv ()", 1)
}
Divtop = parseint (document.getElementById ("Emeng"). style.top,10)
document.getElementById ("Emeng"). Style.top = DivTop-1
}
catch (e) {}
}
function Closediv ()
{
document.getElementById (' Emeng '). style.visibility= ' hidden ';
if (Objtimer) window.clearinterval (Objtimer)
}
</script>
<div Id=emeng style= ' border-right: #455690 1px solid; Border-top: #a6b4cf 1px solid; z-index:99999; left:0px; Visibility:hidden; Border-left: #a6b4cf 1px solid; width:180px; Border-bottom: #455690 1px solid; Position:absolute; top:0px; height:116px; Background-color: #c9d3f3 ' >
<table style= ' border-top: #ffffff 1px solid; Border-left: #ffffff 1px solid ' cellspacing=0 cellpadding=0 width= ' 100% ' bgcolor= #cfdef4 border=0><tbody>
<TR>
&LT;TD style= ' font-size:12px; Background-image:url (msgtopbg.gif); COLOR: #0f2c8c ' width=30 height=24></td>
&LT;TD style= ' Font-weight:normal; font-size:12px; Background-image:url (msgtopbg.gif); COLOR: #1f336b; padding-top:4px; padding-left:4px ' valign=center width= ' 100% ' > Birthday tips:</td>
&LT;TD style= ' Background-image:url (msgtopbg.gif); padding-top:2px; padding-right:2px ' Valign=center align=right width=19><span title= close style= ' cursor:hand;color:red;font-size : 12px;font-weight:bold;margin-right:4px ' Onclick=closediv () >x</span><!----></td>
</TR>
<TR>
&LT;TD style= ' padding-right:1px; Background-image:url (1msgbottombg.jpg); padding-bottom:1px ' colspan=3 height=90> <div style= ' border-right: #b9c9ef 1px solid; padding-right:13px; Border-top: #728eb8 1px solid; padding-left:13px; font-size:12px; padding-bottom:13px; Border-left: #728eb8 1px solid; width:100%; COLOR: #1f336b; padding-top:18px; Border-bottom: #b9c9ef 1px solid; height:100% ' > The upcoming birthday members have:<br><br> <div align=center style= ' Word-break:break-all ' >
<%i=1
Do as not rs.eof
Response.Write ("<a href= '/system/admmember/edit.asp?id=" &rs (0) & "' title= ' ><font color= ' red ' > "&rs (1) &" </font></a> ("&month (RS (2)) &"-&day (RS (2)) & ")"
If I mod 2 =0 then Response. Write ("</br>")
Rs.movenext
I=i+1
Loop%></div></div> </TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<% End If
Rs.close
Set rs=nothing
Conn.close ()
Set Conn=nothing%>


Method Three:
SQL Server:
<%
If month (now ()) =12 and Day (now ()) >24 Then
sSQL = "Select Foodid, Strname, Timeid from Tfood where" DateDiff (D,getdate (), DateAdd (Year,datediff ()) <=200 and DateDiff (D,getdate (), DateAdd (Year,datediff (Year,timeid,getdate ()), Timeid)) >=0) Or (Timeid))) DateDiff (D,getdate (), DateAdd (Year,datediff (Year,timeid,getdate ()) +1,timeid)) <=200 and DateDiff (D,getdate (), DATEADD (Year,datediff (Year,timeid,getdate ()) +1,timeid) >=0) "
Else
sSQL = "Select Foodid, Strname, Timeid from Tfood where" DateDiff (D,getdate (), DateAdd (Year,datediff ()), Timeid) <=200 and DateDiff (D,getdate (), DateAdd (Year,datediff (Year,timeid,getdate ()), Timeid)) >=0) "
End If
%>
Access:
<%
If month (now ()) =12 and Day (now ()) >24 Then
sSQL = "SELECT *
From customers
WHERE (DateDiff (' d ', date (), DateAdd (' yyyy ', datediff (' yyyy ', birthday,date ()), birthday)) <=5 and DateDiff (' d ', date (), DateAdd (' yyyy ', datediff (' yyyy ', birthday,date (), birthday)) >=0) Or (DateDiff (' d ', date (), DateAdd (' yyyy '), DateDiff (' yyyy ', birthday,date ()) +1,birthday) <=5 and DateDiff (' d ', date (), DateAdd (' yyyy ', datediff (' yyyy '), Birthday,date ()) +1,birthday) >=0);
Else
sSQL = "SELECT *
From customers
WHERE (DateDiff (' d ', date (), DateAdd (' yyyy ', DateDiff (' yyyy ', [Birthday],date ()), [birthday]) <=5 and DateDiff (' d '), Date (), DateAdd (' yyyy ', DateDiff (' yyyy ', [Birthday],date ()), [birthday]) >=0); "
End If
%>

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.