![]() |
![]() |
We are currently migrating this forum over to our HelpSystems domain. Please post all new threads in our new HelpSystems Community Portal. |
![]() |
|
![]() |
AutoMate Discussion | ![]() |
Topic Title: evaluating time expressions Topic Summary: Created On: 06/07/2012 10:06 AM Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
||||||||||
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
|
||||||||||
|
||||||||||
![]() |
||||||||||
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.
|
||||||||||
|
||||||||||
![]() |
||||||||||
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.
------------------------- Jean Delfosse - Automate Beta Tester Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
Thanks Jean ... always validating to hear from a trusted source!
It's actually working well!
|
||||||||||
|
||||||||||
![]() |
||||||||||
You're welcome, Brian
------------------------- Jean Delfosse - Automate Beta Tester Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4 ![]() |
||||||||||
|
FuseTalk Enterprise Edition v4.0 - © 1999-2021 FuseTalk Inc. All rights reserved.