Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Current_Date Query Help

Status
Not open for further replies.

vetteguy69

Technical User
Feb 22, 2002
13
0
0
US
Hello,
I am making a data driven site and want an admin page to display a list of people whose birthdays are in the next 14 days based on data from a MySQL database. How would I devise the SQL query to take in the current date and show me the birthdays from the database who are within 14 days of the current date, then display that nicely in a HTML table?
Any help is appreciated.
-vetteguy69
 
u could try this:

<%@ Language=VBScript %>
<%
dim d, f

d = date() 'get the date of today
f = d + 14 'get the date after 14 days

'setting up the database connection

dim conn, rs, cmd

Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.Open &quot;DSN=e-Site;UID=sa;PASSWORD=999999;&quot;

set rs = server.CreateObject (&quot;ADODB.recordset&quot;)

'sql statement

rs.Open &quot;Select * from testing where birthday >= '&quot; & d & &quot;' and birthday <= '&quot; & f & &quot;'&quot;, conn, 2, 2

%>
<html>
<head>
</head>
<body>
<table>
<tr>
<td>User</td>
<td>Birthday</td>
</tr>
<%

if rs.EOF = false then
do until rs.EOF
Response.Write &quot;<tr>&quot;
Response.Write &quot;<td>&quot; & rs.Fields(0) & &quot;</td>&quot;
Response.Write &quot;<td>&quot; & rs.Fields(1) & &quot;</td>&quot;
Response.Write &quot;</tr>&quot;
rs.MoveNext
loop
end if
%>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top