Logo Background

Sysdate-1 DOS Batch Command

  • To echo sysdate-1 output from DOS batch file was not straight forward as we can do in UNIX Shell Script.

    First, as we know that we can output today date as echo %date% or echo %sysdate% in DOS command prompt.

    However, getting the yesterday date was not simple. You need a series of date formatting command in DOS prompt.

    You can copy and paste the following command in your batch files which will output yesterday date.

    @echo off
    set dates=%date:~7,2%
    set /A day  =%dates% - 1
    set /A month=%date:~4,2%
    set /A year =%date:~10,4%
    echo %day%/%month%/%year%
Leave a Comment