logo
Previous Thread
Next Thread
Print Thread
Joined: Mar 2005
Posts: 1
P
pupadu Offline OP
Newbie
OP Offline
Newbie
P
Joined: Mar 2005
Posts: 1
Hello everyone and anyone. I'm new to ASP and this forum. So please bear with me. I had someone help me with this script which works great. It's purpose is to (1) generate times in time given increments and (2) compare these times to data in a particular database field (MSSQL). If any of the generated times match the database data, the matching generated times are not to display. I attempted to tweak it a little to see if I could do this. Here's the code:

<%
Dim varSatOpen
Dim varSatClosed
Dim varSatapptframe
Dim addTime
Dim newTime 'what I added
Dim whatTime 'what I added

dim dt() : redim dt(-1)

varSatOpen = ("08:00:00")
varSatClosed = ("17:00:00")
varSatapptframe = "30"
addTime = dateadd("h",cint("0"),varSatOpen)
response.write addtime
newTime = ("09:00:00") 'what I've added
whatTime = dateadd("h",cint("0"),newTime) 'what I've added

Do While addTime < dateadd("h",cint("0"),varSatclosed)
addTime = DateAdd("n",cint(varSatapptframe),addTime)
redim preserve dt(ubound(dt)+1)
dt(ubound(dt))=addTime
If whatTime <> dt(ubound(dt)) Then 'what I've added
response.write replace(string(1," ")," ","<br/>") & dt(ubound(dt)) 'part of original script
End If 'what I've added
Loop
%>

It works fine until the variable "newTime" is changed to times such as "08:00:00", "08:30:00", or "14:30:00". These times continue to display when they shouldn't. Any ideas what I've done wrong?

Again, any and all help is greatly appreciated.

Sponsored Post Advertisement
Joined: Jan 2004
Posts: 22,934
Likes: 4
BellaOnline Editor
Highest Posting Power Known to Humanity
Offline
BellaOnline Editor
Highest Posting Power Known to Humanity
Joined: Jan 2004
Posts: 22,934
Likes: 4
First, why are you bothering to do the dateadds with a value of zero? You're adding zero to something? And if you're going to add zero, why add zero as the "int value of the character 0" instead of just adding the numeric zero?

Just what is replace(string(1," ")," ","<br/>") supposed to be writing out? <img src="/images/graemlins/smile.gif" alt="" />

Let's say that your NewTime is 8:00. The very first thing you do in your while loop is add 30 seconds to your starting time - so now SatOpen. So your AddTime is 8:30. Those obviously aren't the same, so it's going to write it out.

You really need to read through my site and go back to the basics <img src="/images/graemlins/smile.gif" alt="" /> This code is a little convoluted. A loop is a very basic structure, and I cover this sort of thing step by step. I also cover the basics of troubleshooting - always write out BOTH values in each loop run, so you can clearly see what each value is. That will make the problems quite obvious, if you do a response.write of both the whattime and dt(uboudt(dt)) right before each 'if'.


Lisa Shea, Low Carb and Video Games Editor
Low Carb Forum

Moderated by  Lisa LowCarb 

Link Copied to Clipboard
Brand New Posts
Astro Women - Birthdays
by Mona - Astronomy - 04/26/24 04:34 PM
2024 - on this day in the past ...
by Mona - Astronomy - 04/26/24 04:27 PM
Psalm for the day
by Angie - 04/26/24 02:20 PM
Inspiration Quote
by Angie - 04/25/24 07:21 PM
Review of Boost Your Online Brand: Make Creative A
by Digital Art and Animation - 04/25/24 07:04 PM
Mother's Day Gift Ideas to Sew
by Cheryl - Sewing Editor - 04/24/24 06:08 PM
Check Out My New Website Selective Focus
by Angela - Drama Movies - 04/24/24 01:47 PM
Sew a Garden Flag
by Cheryl - Sewing Editor - 04/17/24 01:24 PM
Review - Notion for Pattern Designers: Plan, Organ
by Digital Art and Animation - 04/17/24 12:35 AM
Review - Create a Portfolio with Adobe Indesign
by Digital Art and Animation - 04/17/24 12:32 AM
Sponsor
Safety
We take forum safety very seriously here at BellaOnline. Please be sure to read through our Forum Guidelines. Let us know if you have any questions or comments!
Privacy
This forum uses cookies to ensure smooth navigation from page to page of a thread. If you choose to register and provide your email, that email is solely used to get your password to you and updates on any topics you choose to watch. Nothing else. Ask with any questions!


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2022 Minerva WebWorks LLC. All rights reserved.


Powered by UBB.threads™ PHP Forum Software 7.7.5