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,550 of 42,547   
   Tim Meddick to Fairfax   
   Re: Changing date output format to yyyy.   
   06 Nov 12 16:31:57   
   
   From: timmeddick@o2.co.uk   
      
   Forgive me; but I always try to get a handle on the bigger picture :-  It   
   could be as simple as you are setting the date/time format in Regional   
   Settings, but then, perhaps, you are not refreshing the [cmd.exe] window.   
   That is; closing all instances of [cmd.exe] and re-opening another *after*   
   Regional Settings has been dismissed.   
      
   When you [re]set the short date:   
      
   "Control Panel" > "Regional and Language Options" >   
      
   "Regional Options" (Tab) > "Customize" (Button) >   
      
   "Date" (Tab)  > "Short Date" (Area)   
      
   ...if you choose :  yyyy-MM-dd   
   ...(with "Date Seperator" set to :  "-" ) the %DATE% variable (in a Command   
   Prompt window) will look like :  2012-11-06   
      
   ...Setting it to :  yyyy-MMM-dd   
   ...and the %DATE% variable will look like :  2012-Nov-06   
      
   *NB you do not have to stick to the options in the drop-down box of the   
   Date Format setting - it also accepts keyboard-typed-input.   
      
   You will need to change the "Date Seperator" setting (to; "-"), as other   
   characters (i.e.; "/") are not helpful when using the %DATE% variable for   
   naming files.   
      
   However, the "Time" format setting in Regional Options has *no* effect on   
   the format of the %TIME% variable, and will always remain: HH:MM:SS.UU or   
   16:01:37.66   
      
   ==   
      
   Cheers,    Tim Meddick,    Peckham, London.    :-)   
      
      
   P.S. The above settings (short) "Date" and "Time", will *both* always   
   effect the output of the Command Prompt's "Time" and "Date" commands :   
      
   C:\>time /t   
   04:18pm   
      
   C:\>date /t   
   2012-11-06   
      
   ...whereas, it is only the %TIME% variable which is unaffected by any   
   modified settings.   
      
   "Fairfax"  wrote in message   
   news:3hrh98tmltlt5qdekese8jnvol2tc34t56@4ax.com...   
   > Good Morning!   
   >   
   > I have a batch file that works very well in creating a backup copy:   
   >   
   > copy "F:\TIMER-WORK\Time Worked Calculator\APP- TWCalc\twc.ses"   
   > "F:\TIMER-WORK\Time Worked Calculator\APP- TWCalc\zBKP- twc.ses -   
   > %DATE%., %TIME:~0,2%h%TIME:~3,2%m%TIME:~6,2%s.ses"   
   >   
   > Because my regional settings at home work, I get the correct output of   
   > part of the date, in yyyy.mm.dd.(day missing).   
   >   
   > At work (also with WinXP), I edit the regional settings but they don't   
   > stick.   
   >   
   > How can I change the %DATE% above so that it works to give me   
   > yyyy.mm.dd.ddd?   
   >   
   > From this page here,   
   > http://blueonionsoftware.com/blog.aspx?p=40656a9d-021b-4061-b2   
   6-36ad5211f4b2,   
   > I tried this:   
   >   
   > %DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%.%DATE:~0,3%   
   >   
   > but I got gobbledook in the output file's name for the date.   
   > Supposedly the above breaks the date down into yyyy.mm.dd.ddd but I   
   > get this type of mangled output:   
   >   
   > zBKP- twc.ses - 1.06..1..0.201,  6h05m22s.ses   
   >   
   > instead of this, which %DATE% gives which I have to then manually edit   
   > each time:   
   >   
   > zBKP- twc.ses - 2012.11.06.,  6h05m27s.ses   
   >   
   > TIA!   
   >   
   > Cheers.   
      
   --- 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