Time format in mysql and asp Hi, I have a database with a record named classes. One of the fields in the record is time set to type time in a mysql database. I am trying to call a list of classes based on the time of day, for example if it is 4 p.m. I want to list all classes that are on today at 4 p.m. or later. I want to list the first three in one colum and the second three in the second column. The code I have now will list the class names but shows nothing. The time is listed in the database as default format 00:00:00 but I am trying to get it to show as 4:00 p.m. or even 4:00 PM. Below is the code I have:
<%
rs.Open "SELECT classes.classID, classes.classType, classes.className, classes.day, TIME_FORMAT(classes.time,'%h:%i %p') as classTime FROM classes WHERE classes.day='" & TodayDay & "' AND classes.time >= CURRENT_TIME() ORDER BY classes.time LIMIT 3", conDB
%>
<tr>
<td width="49%" valign="top" class="bodyTxt">
<%
count = 1
DO WHILE NOT rs.EOF
if NOT rs.EOF THEN
if count = 3 THEN
lastTime = classTime
id = rs("classID")
ELSE
END if
response.Write("<span class='headBox'> " & rs("className") & ": </span> " & classTime & "<br>")
Else
END if
count = count + 1
rs.MoveNext
Loop
rs.Close
%>
</td>
<td width="2%"> </td>
<td width="49%" valign="top" class="bodyTxt">
<%
rs.Open "SELECT * FROM classes WHERE classes.day='" & TodayDay & "' ORDER BY classes.classID LIMIT 4", conDB
if NOT lastTime ="" THEN
DO WHILE rs.EOF
if NOT rs("time") ="" AND rs("time") >= lastTime AND rs("classID") > id THEN
response.Write("<span class='headBox'> " & rs("className") & ": </span> " & rs("time") & "<br>")
Else
END if
rs.MoveNext
Loop
ELSE
END if
rs.Close
%>
</td>
Any help would be greatly appreciated!
judo2000 |