Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: evaluating time expressions
Topic Summary:
Created On: 06/07/2012 10:06 AM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
 06/07/2012 10:06 AM
User is offline View Users Profile Print this message

Author Icon
BrianPearson
Expert (100-199)

Posts: 149
Joined: 04/08/2005

I have a database field that stores the time I want to execute a particular task. My task looks at the current time (which I've formatted to just be H:MM) vs. the db field Time1. If it's the correct time, then everything works great.

I'm executing the task every 15 minutes.

However given that I'm in a couple of different server environments, I want to give it some wiggle room. If CurrentTime-5 >=Time1 OR CurrentTime+5<=Time1 I want to execute the task.

I'm having a hard time adding and subtracting the times and I'm reading all of the help files and testing ... I may get it, but thought I'd see if anyone else has already dealt with this in a better way than me stumbling on it.

Thanks

 Category Survey
 06/07/2012 10:58 AM
User is offline View Users Profile Print this message

Author Icon
BrianPearson
Expert (100-199)

Posts: 149
Joined: 04/08/2005

So I'm sure this is a lame way to do it, but I'm executing a SQL query: Select dateadd(mi, -5, getdate()) that gives me 5 minutes less than my current time, and another one: Select dateadd(mi, -+5, getdate()) for 5 minutes after current time, storing both of them to variables and then comparing my execution time against them.

Again, if anyone has a more elegant solution I'd love to get it ... I'd also like to better know how to adjust times in Automate using native functions ... but this will probably work fine for now.

 Category Survey
 06/07/2012 01:05 PM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Brian,
I may misunderstand your problem, but IMHO there is no better way than SQL functions
I think querying ABS(DATEDIFF(mi,Time1,GetDate()) and comparing it to 5 is the simplest way. Just similar to yours, but a little simpler, since there is no date to store in variables, which is often tricky.

To adjust time in Automate, functions dateadd and datediff from the standard functions set are usable.

 Category Survey
AutoMate BPA Server 8 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 06/07/2012 01:12 PM
User is offline View Users Profile Print this message

Author Icon
BrianPearson
Expert (100-199)

Posts: 149
Joined: 04/08/2005

Thanks Jean ... always validating to hear from a trusted source!

It's actually working well!

 Category Survey
 06/07/2012 09:40 PM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

You're welcome, Brian

 Category Survey
AutoMate BPA Server 8 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 1672 guests browsing this forum, which makes a total of 1672 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2020 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog