1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Batch file date parsing ?

Discussion in 'Windows XP' started by captjlddavis, 2007/07/05.

  1. 2007/07/05
    captjlddavis

    captjlddavis Well-Known Member Thread Starter

    Joined:
    2002/09/13
    Messages:
    588
    Likes Received:
    3
    Good day to all.
    Problem with date in batch file:
    The following is from:
    Use the Current Date in a Windows XP Batch File
    http://findarticles.com/p/articles/mi_zdpcm/is_200406/ai_ziff128194

    it says:
    I created a batch file:

    jld.bat
    FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%J%%K%%L

    ECHO The value is "%mydate% "

    It returns "the value is " 042007

    Not "07042007"

    However if I change the file to read:
    FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%I%%J%%K%%L
    I added the "%%I" to the string

    it returns the value = "07042007 "

    I would like the returned value to be: "20070704 "

    It used to work as I want, but something has changed....the only place that I have dinked around is in CP - region settings, I set time to display 24h clock.

    Any insight is gretly appreciated.
     
  2. 2007/07/05
    captjlddavis

    captjlddavis Well-Known Member Thread Starter

    Joined:
    2002/09/13
    Messages:
    588
    Likes Received:
    3
    I think I found the problem.....:eek:

    Date setting in CP - Regional & language - Customize date
    short date format = M/d/yyyy ( works like it is supposed to )
    I had MM/dd/yyyy - and it don't work.......

    FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%L%%J%%K

    ECHO The value is "%mydate% "

    returns:
    20070704

    sorry for any inconvenience

    regards:captjlddavis
     
    Last edited: 2007/07/05

  3. to hide this advert.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.