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 40,741 of 42,547   
   foxidrive to Anton Bayer   
   Re: Year Month Day Hour Minute Second   
   04 Sep 13 03:53:37   
   
   From: not@this.address.invalid   
      
   On 4/09/2013 03:38, Anton Bayer wrote:   
   > just to add how I do it my way:   
      
   Your way is not robust, as you read the variables multiple times and the hour   
   could change when you are   
   reading the minutes, for example.   
      
   If you want to use %date% and %time% then read them into a variable once,   
   before you start:   
      
   set var1=%date%   
   set var2=%time%   
      
   and then manipulate var1 and var2   
      
   > SET YYYY=%date:~-4%   
   > SET YY=%date:~-2%   
   > SET MM=%date:~-7,2%   
   > SET DD=%date:~-10,2%   
   >   
   > SET HH=%time:~-11,2%   
   > SET NN=%time:~-8,2%   
   > SET SS=%time:~-5,2%   
   >   
   > SET BKUPDATE=%YYYY%-%MM%-%DD%   
   > SET BKUPTIME=%HH%:%NN%:%SS%   
      
   A problem with this is that %date% and %time% are not fixed formats and can   
   vary from computer to   
   computer.  Your code will work for you on a single machine, but it isn't   
   transferable to another machine   
   without you knowing the format and testing it again.   
      
   It's better to use VBS or Wmic or another tool that provides a known format.   
      
      
      
   --   
   foxi   
      
   --- 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