WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: MW4 on December 20, 2017, 09:31:55 AM

Title: Start script if not between two times
Post by: MW4 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?
Title: Re: Start script if not between two times
Post by: td on December 20, 2017, 09:49:06 AM
Many ways to do this.  Here is but one:

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


I sure there better approaches.
Title: Re: Start script if not between two times
Post by: MW4 on December 20, 2017, 10:02:03 AM
that's it, it's been a long while since I used time code.

Thanks!
Title: Re: Start script if not between two times
Post by: MW4 on December 20, 2017, 10:06:08 AM
if it's 1am  is it 010000 or 10000 ?
Title: Re: Start script if not between two times
Post by: td 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.
Title: Re: Start script if not between two times
Post by: MW4 on December 20, 2017, 11:35:30 AM
Perfect!!

Thanks again!