« Previous Next »

Not Answered Thread: How do you convert date format from dd/mm/yyyy to yyMMdd?

Last post 11-02-2009 1:36 PM by M Hare. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 10-22-2009, 4:42 AM

    • thaichi23
    • Not Ranked
    • Joined on 10-20-2009, 10:44 AM
    • Posts 4

    How do you convert date format from dd/mm/yyyy to yyMMdd?

    Hello all,

    I have my IIS to record daily so the log name is ex091022.log.  I want logparser to find the log that has the current date similar to "select * from ex%date%.log"

    The only problem is that %date% returns 10/22/09 and that will not automatically grab the right log. I want to grab the date in the yyMMdd format.  Is this possible?

     My logparser statement works great but this is the only problem.  I am going to save the logparser query as a .bat file and let task schedular run this everday at a certain time so that way it automatically grabs the current date's log and slaps it into SQL. 

  • 11-02-2009, 1:36 PM In reply to

    • M Hare
    • Not Ranked
    • Joined on 11-02-2009, 1:33 PM
    • Posts 1

    Re: How do you convert date format from dd/mm/yyyy to yyMMdd?

    Add this line to the beginning of your batch file

    for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do set jobday=%%c%%a%%b

    Now you can use %jobday% anywhere else in your batch file.

Page 1 of 1 (2 items)
Microsoft Communities