Solved

Execute a Sub every hour

Posted on 2013-01-18
4
293 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
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 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

895 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

11 Experts available now in Live!

Get 1:1 Help Now