Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Execute a Sub every hour

Posted on 2013-01-18
4
Medium Priority
?
300 Views
Last Modified: 2013-01-19
Hello Experts,

I need to execute a sub routine every hour, and I have the following code to so, but it's not happening...

	If (Session("getRates") = "") Or (CDate(Session("getRatesTime")) > Now()) Then
		
		'Call UpdateRates
		
		Session("getRates") = False
	
		'Renew Rates every hour
		Session("getRatesTime") = DateAdd("s", 3, Now())	'DateAdd Intervals: s=secs; n=minutes; h=hrs

	End If

Response.Write("ts = " & Session("getRatesTime") & "<br>")
Response.Write("now = " & Now())

Open in new window


It executes once, whern getRates = "", then the first Writeline doesnt change.

Any ideas?

I have it set to 3s for this test...

Thank you.
0
Comment
Question by:APD_Toronto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 total points
ID: 38795325
Try switching it around, also you don't need CDate:
	If (Session("getRates") = "") Or (Session("getRatesTime") < Now()) Then

Open in new window

0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 38796163
while previos comment is probably the correct test, what method did you have in mind for getting the script to wait the 3600 seconds.
What causes the script to reload ?  Page.Redirect ?

your asp page is going to be running continuously.... is that what you expect ?

executing every hour, i think it would be more efficient to have the script run using windows scheduler and update a background file with the data but that may not suit your users .
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38796167
I do agree 100% that this should not be  run as asp page, but by a scheduler
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38796177
I assumed it would not be running continuously but rather check on each use of a page (or even any page on a site via a global include file) whether a set of information needed refreshing.

EDIT: For that of course you may need to use Application instead of Session. But if you just need this within each individual user's session then it should do the job.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question