home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 41,183 of 42,547   
   foxidrive to Dr J R Stockton   
   Re: How to check time in a .BAT?   
   31 Aug 15 13:39:27   
   
   From: foxidrive@server.invalid   
      
   On 31/08/2015 02:59, Dr J R Stockton wrote:   
   >> >On 29/08/2015 18:00, helpMePlease wrote:   
   >>>> >>>example of running a command only if before 8:00 am:   
   >> >   
   >> >The post you quoted is from 1999 - this is a command for a modern   
   >> >version of Windows which may work.   
   >> >   
   >> >   
   >> >if %time:~0,2%%time:~3,2% LEQ 800 echo the time is before 8am.   
      
   > For those preferring a 12-hr clock, is there a risk of the command also   
   > running in the afternoon?   
      
   Absolutely, John.  Thanks.   
      
   I think those people would have to use this:   
      
   if %time:~0,2%%time:~3,2% LSS 800 if /i "%time:~6,2%"=="am" (   
       echo the time is before 8am.   
   )   
      
      
   The original code also needs LSS rather than LEQ to fix that extra minute,   
   but a solution using WMIC is more robust.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca