Solved

Execute a Sub every hour

Posted on 2013-01-18
4
292 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
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
Comment Utility
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)
Comment Utility
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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now