...

View Full Version : Trouble with hour(now) and minute(now)



oversoul
01-27-2005, 12:45 AM
Hello, I am trying to make a form show at a specific time everday on my webpage. I am inserting the numbers of the the time in a database and posting it to the page. For some reason this is not working for me.

here is my code to help understand what I am doing.


<%
Dim thehour, Theminute, Thesecond
thehour=Hour(now) ' Here we will add 1 to hour in server to make it Central Time
if thehour>12 then
thehour=thehour-12
end if
Theminute=minute(now)
if Theminute<10 then
Theminute="0" & Theminute
end if
Thesecond=second(now)
if Thesecond<10 then
Thesecond="0" & Thesecond
end if
%>
The time is: <%=thehour %>:<%=Theminute %>:<%=Thesecond %><br>
<%
'declare your variables
Dim sSQL, sconnection, srecordset

'declare SQL statement that will query the database
sSQL="SELECT * FROM tblTimes"

'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("access/Totals.mdb")

'create an ADO connection and recordset
Set sconnection = Server.CreateObject("ADODB.Connection")
Set srecordset = Server.CreateObject("ADODB.Recordset")

'Open the connection to the database
sconnection.Open sConnString

'Open the recordset object, execute the SQL statement
srecordset.Open sSQL, sconnection

Dim var1, var2, var3, var4
var1 = Hour(now)
var2 = Hour(now)
var3 = minute(now)
var4 = minute(now)

If (var1>=0) and (var2<=srecordset("bstart")) and (var3<=srecordset("mbstart")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
If (var1>=srecordset("MainStart")) and (var3<=srecordset("MainMin")) and (var2<=srecordset("MainEnd")) and (var4<=srecordset("MainEndMin")) Then
Response.write("<br>")
Response.write("<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='36%'>")
Response.write("<tr>")
Response.write("<td width='18%'>")
Response.write("<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>")
Response.write("<p align='center'>")
Response.write("<input type='hidden' name='cmd' value='_xclick'>")
Response.write("<input type='hidden' name='business' value='info@my-domain.com'>")
Response.write("<input type='hidden' name='item_name' value='1 Day Purchase'>")
Response.write("<input type='hidden' name='amount' value='10.00'>")
Response.write("<input type='hidden' name='no_note' value='1'>")
Response.write("<input type='hidden' name='currency_code' value='USD'>")
Response.write("<input type='hidden' name='notify_url' value='http://www.my-domain.com/validate.asp'>")
Response.write("<input type='hidden' name='return' value='http://www.my-domain.com/confirmation.asp'>")
Response.write("<input type='image' src='images/x-click-but23.gif' border='0' name='submit' align='right'>")
Response.write("<input type='hidden' name='add' value='1'>")
Response.write("</form>")
Response.write("</td>")
Response.write("<td width='182%' align='center'>")
Response.write("<font face='Verdana'><b>$10.00</b></font>")
Response.write("</td>")
Response.write("</tr>")
Response.write("</table>")
Else If (var1>=srecordset("AfterMain")) and (var3>=srecordset("AfterMainMin")) and (var2<=srecordset("EndingAfterMain")) and (var4>=srecordset("EndingAfterMainMin")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has already begun.</b></font>")
Else If (var1>=srecordset("Final1")) and (var3>=srecordset("Final1Min")) and (var2<=srecordset("Final2")) and (var4>=srecordset("Final2Min")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
End If
End If
End If
End If
%>

After all of this, It only runs the first if then portion and none of the others. Why is ti doing this?
Please help, this is urgent....

glenngv
01-27-2005, 03:27 AM
Please enclose the codes in
tags to make it readable. It's hard to read the code if all lines are aligned to the left.

oversoul
01-27-2005, 03:39 AM
There we go.

For some reason it works if I don't use the minute portion of the code, but I need hour and up to the minute.

glenngv
01-27-2005, 06:45 AM
Is it more readable and easier to debug if you put indentions in your code?


If (var1>=0) and (var2<=srecordset("bstart")) and (var3<=srecordset("mbstart")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
If (var1>=srecordset("MainStart")) and (var3<=srecordset("MainMin")) and (var2<=srecordset("MainEnd")) and (var4<=srecordset("MainEndMin")) Then
Response.write("<br>")
Response.write("<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='36%'>")
Response.write("<tr>")
Response.write("<td width='18%'>")
Response.write("<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>")
Response.write("<p align='center'>")
Response.write("<input type='hidden' name='cmd' value='_xclick'>")
Response.write("<input type='hidden' name='business' value='info@my-domain.com'>")
Response.write("<input type='hidden' name='item_name' value='1 Day Purchase'>")
Response.write("<input type='hidden' name='amount' value='10.00'>")
Response.write("<input type='hidden' name='no_note' value='1'>")
Response.write("<input type='hidden' name='currency_code' value='USD'>")
Response.write("<input type='hidden' name='notify_url' value='http://www.my-domain.com/validate.asp'>")
Response.write("<input type='hidden' name='return' value='http://www.my-domain.com/confirmation.asp'>")
Response.write("<input type='image' src='images/x-click-but23.gif' border='0' name='submit' align='right'>")
Response.write("<input type='hidden' name='add' value='1'>")
Response.write("</form>")
Response.write("</td>")
Response.write("<td width='182%' align='center'>")
Response.write("<font face='Verdana'><b>$10.00</b></font>")
Response.write("</td>")
Response.write("</tr>")
Response.write("</table>")
Else
If (var1>=srecordset("AfterMain")) and (var3>=srecordset("AfterMainMin")) and (var2<=srecordset("EndingAfterMain")) and (var4>=srecordset("EndingAfterMainMin")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has already begun.</b></font>")
Else
If (var1>=srecordset("Final1")) and (var3>=srecordset("Final1Min")) and (var2<=srecordset("Final2")) and (var4>=srecordset("Final2Min")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
End If
End If
End If
End If

I don't know if this is what you're after:


If (var1>=0) and (var2<=srecordset("bstart")) and (var3<=srecordset("mbstart")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
If (var1>=srecordset("MainStart")) and (var3<=srecordset("MainMin")) and (var2<=srecordset("MainEnd")) and (var4<=srecordset("MainEndMin")) Then
Response.write("<br>")
Response.write("<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='36%'>")
Response.write("<tr>")
Response.write("<td width='18%'>")
Response.write("<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>")
Response.write("<p align='center'>")
Response.write("<input type='hidden' name='cmd' value='_xclick'>")
Response.write("<input type='hidden' name='business' value='info@my-domain.com'>")
Response.write("<input type='hidden' name='item_name' value='1 Day Purchase'>")
Response.write("<input type='hidden' name='amount' value='10.00'>")
Response.write("<input type='hidden' name='no_note' value='1'>")
Response.write("<input type='hidden' name='currency_code' value='USD'>")
Response.write("<input type='hidden' name='notify_url' value='http://www.my-domain.com/validate.asp'>")
Response.write("<input type='hidden' name='return' value='http://www.my-domain.com/confirmation.asp'>")
Response.write("<input type='image' src='images/x-click-but23.gif' border='0' name='submit' align='right'>")
Response.write("<input type='hidden' name='add' value='1'>")
Response.write("</form>")
Response.write("</td>")
Response.write("<td width='182%' align='center'>")
Response.write("<font face='Verdana'><b>$10.00</b></font>")
Response.write("</td>")
Response.write("</tr>")
Response.write("</table>")
End If
If (var1>=srecordset("AfterMain")) and (var3>=srecordset("AfterMainMin")) and (var2<=srecordset("EndingAfterMain")) and (var4>=srecordset("EndingAfterMainMin")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has already begun.</b></font>")
ElseIf (var1>=srecordset("Final1")) and (var3>=srecordset("Final1Min")) and (var2<=srecordset("Final2")) and (var4>=srecordset("Final2Min")) Then
Response.Write("<font color='#FF0000'><b>Sorry. Today's game has not been picked yet.</b></font>")
End If
End If

oversoul
01-28-2005, 03:03 AM
In my code I am using Indentions. That was just because I pasted it in funny.

Well what happens, is the server that I am grabbing the time from is in eastern time, and I am in central time.

The problem is, the button won't show up, and it just shows a blank space where the button should be.

it displays the first IF THEN statement just fine, but that is all it shows.

I'm stumped as of what to do...

What I want to happen, Is show the first If Then up until I show the button, then after the time range of the button showing, I want the second sentence to show, and then go back to the first IF then.

Am I making any sense? is there an easier way to do this?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum