viewpoint-particle

Author Topic: Start script if not between two times  (Read 1119 times)

MW4

  • Full Member
  • ***
  • Posts: 171
Start script if not between two times
« on: December 20, 2017, 09:31:55 am »
I need to set up a basic if statement that only proceeds if the current time is not between Midnight and 5:20 am.
I'm hung up on syntax

Here's what I'm attempting:

If TimeYmdHms ( ) > 00:01:00 and < 05:20:00
   Quit
Endif

Run Script

Is it two time differentials?

td

  • Tech Support
  • *****
  • Posts: 2770
    • WinBatch
Re: Start script if not between two times
« Reply #1 on: December 20, 2017, 09:49:06 am »
Many ways to do this.  Here is but one:

Code: Winbatch
TimeCurrent = TimeYmdHms()
HMSCurrent  = ItemExtract(4,TimeCurrent,':'):ItemExtract(5,TimeCurrent,':'):ItemExtract(6,TimeCurrent,':')
if HMSCurrent > 235959 && HMSCurrent < 52100 then exit
 

I sure there better approaches.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

MW4

  • Full Member
  • ***
  • Posts: 171
Re: Start script if not between two times
« Reply #2 on: December 20, 2017, 10:02:03 am »
that's it, it's been a long while since I used time code.

Thanks!

MW4

  • Full Member
  • ***
  • Posts: 171
Re: Start script if not between two times
« Reply #3 on: December 20, 2017, 10:06:08 am »
if it's 1am  is it 010000 or 10000 ?

td

  • Tech Support
  • *****
  • Posts: 2770
    • WinBatch
Re: Start script if not between two times
« Reply #4 on: December 20, 2017, 10:59:58 am »
The time values in the example are being used as integers and not strings so a leading zero (0) does not make any difference.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

MW4

  • Full Member
  • ***
  • Posts: 171
Re: Start script if not between two times
« Reply #5 on: December 20, 2017, 11:35:30 am »
Perfect!!

Thanks again!