Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script triggered automatically

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
Dear All,

I am inserting a date into the database, that is 48 hours from the current time, and I call it the expiryDate. What I want to do know is a sort of script that every minute checks this expiryDate in the database with the current date/time and if it is equal, or smaller, then, I change the status code from 1 to 2.

Do you have any ideas on how I can achieve this?

Thanks for your help
 
I would imagine the easiest way to achieve this is to use scheduled tasks.

Write yourself a vb script which does what you want it to (i.e. go through every record in the database once and check the values etc) and save it as a .vb file. (Note there are some slight differences between vbscript in a vb file and an asp file).

Set a scheduled task (Start>Accessories>System>Scheduled Tasks) to run the script once every minute.

I generally use scheduled tasks for stuff that has to happen once a day/week/month, so I have no idea what sort of load performing the task every minute would put on the web server but it would no doubt slow it down a bit.

i hope this helps

Nick (Webmaster)

info@npfx.com
 
Thinking about it, you might not need to do this sort of thing at all.

By doing the above, you will only achieve what is fundamentally recorded in the database anyway - that is by checking the difference between the start and expiry dates.

When are you going to use this information? If it is so that you can pull out the data for displaying on an asp page (i.e. SELECT * WHERE STATUS=1 ), why not just perform the comparison with the sql (i.e. SELECT * WHERE DateDiff('s',StartDate,EndDate) < 0 ). The resultset would be identical either way, and it would save doing all that scheduled task thingy.



Nick (Webmaster)

info@npfx.com
 
Hi Nick

I have to have a scheduled task, so that when the date and time, expires, the status is changed automatically, and so the user cannot log in and see that item.

Unfortunately, I do not know how to write a VB Script cause I have never used VB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top