• Jeff Moden (2/20/2013)


    Can you think of a way to have the date come out in the ISO format of YYYYMMDD to support sortable file names using the batch commands?

    didling with the String manipulation function in shell is a pain, but yes you can do it.

    from what I understand you have to play some tricks to combine variables.

    (I looked at this: http://stackoverflow.com/questions/7846560/how-concatenate-two-variables-in-batch-script)

    anyway, I would start by getting each part of the current DATE into three variables:

    set MM=%DATE:~4,2%

    set DD=%DATE:~7,2%

    set YY=%DATE:~10,4%

    then create your new yymmdd variable by combining them:

    setlocal EnableDelayedExpansion

    set yyyymmdd=!%YY%%MM%%DD%!

    I hate messing with batch scripting because it is so ugly (not like unix shells) but if you are a DBA you end up needing to use it at times.

    The probability of survival is inversely proportional to the angle of arrival.