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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you compare time?

Status
Not open for further replies.

tziviak

Technical User
Oct 10, 2002
128
US
I have start time & end time how do I compare if startTime< endTime?
my code:
EndTime=oRs(&quot;TimeSessionStarted&quot;)
<%if (oRs(&quot;TimeSessionStarted&quot;) < EndTime ) then%>

it doesn't work-the endTime is equal to TimeSessionStarted and it's going into this statement-so it's probably not the correct way to compare it (I even tried decreasing end time by:
EndTime=DateAdd(&quot;n&quot;, -1, oRs(&quot;TimeSessionStarted&quot;))%>
and then testing it-but I still got into the if statement.

I'd appreciate if anyone can help me-or direct me to a good website where I can find out the info
Thanks
 
Off the top of my head I would guess it is doing a string comparison rather than a date comparison. You could use the cDate funciton to convert the data from the db to datetype before assigning it to the variables, tat will work as long as the value from the db is not null.
ie:
Code:
Dim myDate
myDate = cDate(rs(&quot;myDateField&quot;))

-Tarwn 01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Could do it this way

EndTime=formatdatetime(oRs(&quot;TimeSessionStarted&quot;)) Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top