Guest Juan García Posted January 16, 2008 Posted January 16, 2008 I would like to obtain the day of month from the current date in a batch file in a string of two characters. Thank in advance
Guest Pegasus \(MVP\) Posted January 16, 2008 Posted January 16, 2008 Re: Day of date in a batch file "Juan García" <XXnl144039YY@ZZgmail.com> wrote in message news:%231f11WHWIHA.6140@TK2MSFTNGP02.phx.gbl... >I would like to obtain the day of month from the current date in a batch >file in a string of two characters. > Thank in advance > Try this: @echo off echo Day of month=%date:~x,2% or, if you need leading zeros: @echo off set dom=%date:~x,2% if %dom% LSS 10 set dom=0%date:~y,1% echo Day of month=%dom% Note that the format of the variable %date% is country-specific. You must make x=4 and y=5 if you live in a European country, and x=7 and y=8 (untested!) if you live in the USA.
Recommended Posts