?
Solved

A birthday reminder's problem

Posted on 2003-03-06
13
Medium Priority
?
287 Views
Last Modified: 2010-05-18
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
Comment
Question by:yokohama5151
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 3

Expert Comment

by:HMax
ID: 8078477
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
 
LVL 7

Expert Comment

by:markhoy
ID: 8079169
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
 

Author Comment

by:yokohama5151
ID: 8092684
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Wakie
ID: 8092875
<%
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
 

Author Comment

by:yokohama5151
ID: 8093322
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
 
LVL 4

Expert Comment

by:Wakie
ID: 8093345
<%
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
 

Author Comment

by:yokohama5151
ID: 8095265
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
 

Author Comment

by:yokohama5151
ID: 8095266
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
 
LVL 4

Expert Comment

by:Wakie
ID: 8096012
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
 

Author Comment

by:yokohama5151
ID: 8097015
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
 
LVL 4

Accepted Solution

by:
Wakie earned 380 total points
ID: 8097081
Write the value of manyday:

Response.Write manyday

And tell me what the value is.
0
 

Author Comment

by:yokohama5151
ID: 8098135
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
 
LVL 4

Expert Comment

by:Wakie
ID: 8099603
Brilliant!

Pleasure to help :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question