Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    119

    DOS command syntax to get the day number of the current date

    What is the dos command syntax to get the day of the current date.
    For example today is Aug. 24, 2009, the day number should be 24.

    I have a batch file wherein i need to know the day number.
    Below is my sample command script:

    IF %DATE% <= 7
    (
    echo Successful run: Email sent to users containing the final report file
    )

    ELSE

    (
    echo Error: Bugreport (Missing Report) email sent
    )

    Thanks.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    try google
    or consider switching to vbscript as an alternative to dos batch
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Oct 2005
    Posts
    119
    This syntax returns the day number of the current date.

    %Date:~0,2%

    I used this in my IF condition, but when i tried running my batch file, i can't get the result.

    @echo off

    IF %Date:~0,2% > 8

    (
    echo PROCESS 3: successful >> test.log
    echo. >> test.log
    )

    ELSE

    (
    echo PROCESS 4: failure>> test.log
    echo. >> test.log
    )

    pause

    :end

  4. #4
    Join Date
    May 2009
    Location
    India
    Posts
    66
    First off, I think, the arguments ~0,2 represent the positions and are dependant on the setting. Please check this out.

    Secondly, > is a redirection symbol.
    On XP, the batch command sysntax defines variables for string comparison. Help if at the comand prompt will give it to you.

    Here is a sample batch file:
    ***********************************
    @echo off
    REM echo %%date:~0,2%
    SET aa=%date:~0,2%
    echo %aa%
    If %aa% GTR 08 echo Greater than 8
    If %aa% LEQ 07 echo Less than or equal to 7
    echo.
    If %aa% GTR 04 echo Greater than 4
    If %aa% LEQ 03 echo Less than or equal to 3
    ***********************************

    End

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •