[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

A birthday reminder's problem

I have a table called "student" with its field name
called "birthday".

The birthday is in MM/DD/YY format.

The problem is my original script I downloaded from internet is in MM ; DD and YY
each field name). I don't know how to change to my new format.

The souce code is at:

http://www.b2cemall.com/original/Addon/birthday.txt
0
yokohama5151
Asked:
yokohama5151
1 Solution
 
HMaxCommented:
You can split a date in several parts and then adapt your source code.

For example, if the date in MM/DD/YY is 01/02/03, you can change it to DD/MM/YY by doing so

myOldDate = "01/02/03"
myNewDate = Day(myOldDate) & "/" & Month(myOldDate) & "/" & Year(myOldDate)

This will work if the server local date settings are in MM/DD/YY so that myOldDate is read in this format.
0
 
markhoyCommented:
Are you asking how to split the date into DD MM YY from your database field?

myDate=split(rs("birthday"),"/") ' split date fiel on /

dd = myDate(1)
mm = myDate(0)
yy = myDate(2)

use them in your script now as needed.
0
 
yokohama5151Author Commented:
I got a error message :
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'clng'

<%                        
SQLcmd = "Select * From [student] Where birthday Like '%"& nowMon & "%' order by birthday"
Set rs = conn.Execute(SQLcmd)
Do While Not rs.EOF  
                                         
personal = Mid(rs("birthday"),7,2)  
                                               
manyday = Clng(personal)-Day(now)
%>      
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
WakieCommented:
<%
SQLcmd = "Select * From [student] Where birthday '" & nowMon & "' order by birthday"
Set rs = conn.Execute(SQLcmd)
Response.Write SQLcmd & "<br>"
Do While Not rs.EOF
   personal = Mid(rs("birthday"),7,2)
'  manyday = Clng(personal)-Day(now)
   Response.Write "Personal: " & personal & "<br>"
   rs.MoveNext
Loop
%>

Running that code, what result do you get?

Regards,
Wakie.
0
 
yokohama5151Author Commented:
I think you should look at whole code: the the field name for birthday is like: DD-MM-YY or MM-DD-YY since it don't have any effect.

<%
nowMon = Month(now)
nowDay = Day(now)
nowBirth = nowMon & nowDay
%>
<%
SQLcmd = "Select userid,realname,birthday From student where birthday Like '%"& nowBirth & "%' order by birthday"
Set rs = conn.Execute(SQLcmd)            
Do While Not rs.EOF %>
<p align="center"><b><i><font size="3" color="#CC0099">Today isöØ<%=rs("realname")%>öÙ's birthday!!!<br>
</font></i></b>      
<p align="center"><a href="mailto:<%=rs("realname")%>%3c<%=rs("email")%>%3e?subject=Wishing you~~Happy Birthday~~"><font size="2">Please click here to email <%=Right(rs("realname"),2)%>!</font></a>      
 <p></p>          
<% rs.MoveNext            
   Loop %>              
<!--% Next %-->                
<div align="center"><center>        
<table border="0" width="100%" cellspacing="0" cellpadding="0">        
<tr><td valign="top"><p align="center">öŸ<font size="3">
<font color="#008000">This is birthday's list for Month of <%=nowMon%></font></font>
<div align="center"><center>
<table border="0" cellspacing="5" style="border: 2 dotted #FF0000" >
<%                                                         SQLcmd = "Select * From student Where birthday Like '%"& nowMon & "%' order by birthday"
Set rs = conn.Execute(SQLcmd)
Do While Not rs.EOF                                              
personal = Mid(rs("birthday"),7,2)
manyday = Clng(personal)-Day(now)
%>                                                                                  
<tr><td align="center" ><font color="#CC0099" size="2"><%=rs("userid")%></font></td>        <td align="center" ><font color="#800000" size="2"><!--%=rs("A_Voice")%--></font></td>
<td align="center" ><font color="#FF0000" size="2"><%=Right(rs("birthday"),6)%></font></td>   <% If  manyday > 0 and manyday <=6  Then  %><td align="center" >
<font color="#996600" size="1">will be celebrate his birthday!</font></td><% End If %>                        
</tr>                                                                                
<%                                
rs.MoveNext                                                Loop %>
*********************************************************
This code will list out name of this month's birthday. Furthermore, if the birthday is within 6 days from the birthday, it will show a sentence - Happy Birthday Day!
For exp. : Today is 3-8,
Name      Birthday
----      --------
Jason     3 26  
Yen Ying  3 13     Happy Birthday!!!

So the "manyday" should be there.
0
 
WakieCommented:
<%
nowMon = Month(now)
nowDay = Day(now)
nowBirth = nowMon & "/" & nowDay

SQLcmd = "Select * From student where birthday Like '%" & nowBirth & "%' order by birthday"
'response.write sqlcmd
Set rs = conn.Execute(SQLcmd)            
Do While Not rs.EOF
%>
<p align="center"><b><i><font size="3" color="#CC0099">Today isvX<%=rs("realname")%>vY's birthday!!!<br>
</font></i></b>      
<p align="center"><a href="mailto:<%=rs("realname")%>%3c<%=rs("email")%>%3e?subject=Wishing you~~Happy Birthday~~"><font size="2">Please click here to email <%=Right(rs("realname"),2)%>!</font></a>      
<p></p>          
<%
rs.MoveNext            
Loop
%><div align="center"><center>        
<table border="0" width="100%" cellspacing="0" cellpadding="0">        
<tr><td valign="top"><p align="center"><font size="3">
<font color="#008000">This is birthday's list for Month of <%=nowMon%></font></font>
<div align="center"><center>
<table border="0" cellspacing="5" style="border: 2 dotted #FF0000"><%
SQLcmd = "Select * From student Where birthday Like '%"& nowMon & "%' order by birthday"
Set rs = conn.Execute(SQLcmd)
Do While Not rs.EOF                                              
     personal = Mid(rs("birthday"),7,2)
     manyday = Clng(personal)-Day(now)
%>                                                                                  
<tr><td align="center"><font color="#CC0099" size="2"><%=rs("userid")%></font></td>
<td align="center"><font color="#800000" size="2"><!--%=rs("A_Voice")%--></font></td>
<td align="center"><font color="#FF0000" size="2"><%=Right(rs("birthday"),6)%></font></td><%
     If manyday > 0 and manyday <= 6 Then
%><td align="center">
<font color="#996600" size="1">will be celebrate his birthday!</font></td><%
     End If
%>
</tr><%                                
     rs.MoveNext
Loop
%>
0
 
yokohama5151Author Commented:
It seems that I can't run it on my PWS.

Then, I uploaded it to my web site and found that it can run but with something different.

If admin's birthday is 02-3-9 (YY-M-D), it will show :

admin  9/2002

When I chnage <%=Right(rs("birthday"),6)%> to <%=rs("birthday")%>, I will have :

This is birthday's list for Month of 3
admin  3/13/2002

Unfortunately, this didn't show :"will be celebrate his birthday!" since it is within 7 days from admin's birthday.
0
 
yokohama5151Author Commented:
It seems that I can't run it on my PWS.

Then, I uploaded it to my web site and found that it can run but with something different.

If admin's birthday is 02-3-9 (YY-M-D), it will show :

admin  9/2002

When I chnage <%=Right(rs("birthday"),6)%> to <%=rs("birthday")%>, I will have :

This is birthday's list for Month of 3
admin  3/13/2002

Unfortunately, this didn't show :"will be celebrate his birthday!" since it is within 7 days from admin's birthday.
0
 
WakieCommented:
Try this one:

<!--#INCLUDE FILE="setup.asp" -->
<!--#include file="char.asp"-->
<!--#include file="checkuser.asp"-->
<!--#include file="theme.asp"--><%
nowMon = Month(now)
nowDay = Day(now)
nowBirth = nowMon & "/" & nowDay

SQLcmd = "Select * From student where birthday Like '%" & nowBirth & "%' order by birthday"
'response.write sqlcmd
Set rs = conn.Execute(SQLcmd)            
Do While Not rs.EOF
%>
<p align="center"><b><i><font size="3" color="#CC0099">Today isvX<%=rs("realname")%>vY's birthday!!!<br>
</font></i></b>      
<p align="center"><a href="mailto:<%=rs("realname")%>%3c<%=rs("email")%>%3e?subject=Wishing you~~Happy Birthday~~"><font size="2">Please click here to email <%=Right(rs("realname"),2)%>!</font></a>      
<p></p>          
<%
rs.MoveNext            
Loop
%><div align="center"><center>        
<table border="0" width="100%" cellspacing="0" cellpadding="0">        
<tr><td valign="top"><p align="center"><font size="3">
<font color="#008000">This is birthday's list for Month of <%=nowMon%></font></font>
<div align="center"><center>
<table border="0" cellspacing="5" style="border: 2 dotted #FF0000"><%
SQLcmd = "Select * From student Where birthday Like '%"& nowMon & "%' order by birthday"
Set rs = conn.Execute(SQLcmd)
Do While Not rs.EOF
     manyday = Day(now) - Clng(day(rs("birthday")))
%>                                                                                  
<tr><td align="center"><font color="#CC0099" size="2"><%=rs("userid")%></font></td>
<td align="center"><font color="#800000" size="2"><!--%=rs("A_Voice")%--></font></td>
<td align="center"><font color="#FF0000" size="2"><%'=Right(rs("birthday"),6)%><%=rs("birthday")%></font></td><%
     If manyday > 0 and manyday <= 6 Then
%><td align="center">
<font color="#996600" size="1">will be celebrate his birthday!</font></td><%
     End If
%>
</tr><%                                
     rs.MoveNext
Loop
%>

Regards,
Wakie.
0
 
yokohama5151Author Commented:
Still don't have "will be celebrate his birthday!".
And the result is as fellow:

This is birthday's list for Month of 3
admin  3/13/2002
0
 
WakieCommented:
Write the value of manyday:

Response.Write manyday

And tell me what the value is.
0
 
yokohama5151Author Commented:
Response.Write manyday:

-3

So I changed to
manyday =  Clng(day(rs("birthday"))) - Day(now))

and have this :
admin  3/13/2002 will be celebrate his birthday!

Thanks a lot!
0
 
WakieCommented:
Brilliant!

Pleasure to help :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now