Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2005, 02:12 PM
Registered User
 
Join Date: Mar 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Looping Time

Hello to everyone and anyone. I'm new to ASP and to this forum.

Here's what I'm having a problem with. I need ASP to do the following:
(1) take the starttime in one database field (SQL Server), (08:00:00 AM)
(2) take the endtime in another database field (SQL Server), (05:00:00 PM)
(3) add 30 minutes to the starttime, and
(4) display the result of the each new starttime.

It needs to continue to do these steps until the new starttime is less than or equal to the endtime. My code produces an infinite loop for whatever reason. Here's my code.

<%
Dim strSatOpen
Dim strSatClosed
Dim strSatapptframe
Dim addTime

strSatOpen = ("8:00 AM")
strSatClosed = ("5:00 PM")
strSatapptframe = "30"
addTime = DateAdd("n",strSatapptframe,strSatOpen)

Do While addTime <= strSatclosed
Response.Write "<br>" & addTime
addTime = addTime + strSatapptframe
%>

Any and all help is greatly appreciated. :)

 
Old March 17th, 2005, 07:12 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Try:
----------------------
strSatOpen = cDate("8:00:00 AM")
strSatClosed = cdate("5:00:00 PM")
strSatapptframe = "30"
addTime = DateAdd("n",strSatapptframe,strSatOpen)

Do Until cdate(addTime) = cDate(strSatClosed)
   addTime = DateAdd("n",strSatapptframe,addTime)
   response.write cdate(addTime) & "<br>"
loop
----------------------

FYI: The cDate function - Returns an expression that has been converted to a Variant of subtype Date

BTW: you forgot the LOOP - All Do While and Do Until conditions must be closed with a LOOP



Wind is your friend
Matt
 
Old March 17th, 2005, 07:26 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

pupadu

People will be less inclined to answer your questions if you cross post (unless you clearly get no response in one area)

Wind is your friend
Matt
 
Old March 19th, 2005, 12:57 AM
Registered User
 
Join Date: Mar 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the tip and the solution, mat41. I'm new to forum so please bear with me.






Similar Threads
Thread Thread Starter Forum Replies Last Post
synchronizing pocket pc time with desktop time bobbyrayudu83 C# 1 April 2nd, 2011 04:28 AM
Time Shift time in minus time out lechalas Beginning VB 6 1 August 11th, 2008 01:56 PM
time zone & day light time rajn ASP.NET 1.0 and 1.1 Professional 0 August 7th, 2007 05:02 PM
Using xs:time to generate time in desired format krayan001 XSLT 0 June 27th, 2005 04:28 PM
Looping Time pupadu Classic ASP Basics 1 March 17th, 2005 07:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.