Change format for date

Microsoft Windows 7 professional 32-bit
December 5, 2009 at 16:14:52
Specs: Windows 7
Help anyone??? I am writing a batch file and need to have the date displayed like this:

"Today is Tuesday 24 November 2009" vs. standard dos output of Tue 11/24/2009

I know this should be just a one or two line code, but am getting frustrated and just can't seem to put it all together...Please help if you can.

Thanks all!!

See More: Change format for date

Report •

December 5, 2009 at 21:02:15
@echo off
setlocal enabledelayedexpansion
set Fr=Friday
set Sa=Saturday
... (do same for Sa to Su)
set Su=Sunday
set 01=January
... (do same for 01 to 12)
set 12=December
set dd=%date%
set cc=!dd:~0,1!
set ff=!dd:~7,2!
set yy=!dd:~10,4!
set ee=!dd:~4,2!
set dd=!%cc%!
set ee=!%ee%!

echo today is %dd% %ff% %ee% %yy%

Report •

December 6, 2009 at 00:07:56
A comination of VBS and Batch scripting, not fully tested:

@echo off

set vbsfile=%temp%\vbsfile.vbs
echo       Thisdate = (Date(^)^)
echo       DateYear = DatePart("YYYY", Thisdate^)
echo      DateMonth = DatePart("M"   , Thisdate^)
echo        DateDay = DatePart("D"   , Thisdate^)
echo  WeekDayNumber = DatePart("W"   , Thisdate^)
echo    DayNameFull = WeekdayName(WeekDayNumber,False^)
echo  MonthNameFull = MonthName(DateMonth,False^)
echo Wscript.Echo DateYear^&" "^&DateMonth^&" "^&DateDay^&" "^&Month^
NameFull^&" "^&DayNameFull

for /f "tokens=1-5 delims= " %%A in ('cscript //nologo %vbsfile%') do (
   set yyyy=%%A
   set mm=%%B
   set dd=%%C
   set mthal=%%D
   set dowal=%%E
Del %vbsfile%

echo     Today's date is %dowal%, %dd% %mthal%, %yyyy%

Report •

December 6, 2009 at 00:10:07
nbrane...this rocked for the most is not listing the day of the week though...I'm wondering if where the code states:

"echo today is %dd% %ff% %ee% %yy%" I am wondering where the day of the week is??

Report •

Related Solutions

December 6, 2009 at 11:13:48
this part *should* have set up the week days:
set Fr=Friday
set Sa=Saturday
... (do same for Sa to Su)
set Su=Sunday
set Mo=Monday
set Tu=Tuesday
set We=Wednedsay
set Th=Thursday

and this *should* have assigned the correct one:
set dd=%date%
::this one was wrong! sorry again
set cc=!dd:~0,1! supposed to be: set cc=!dd:~0,2!
set dd=!%cc%!

which is abominable coding technique! (i just transplanted a test-version from my Xp that was slopped together). I should have created a new var. instead of recycling "dd" which is confusing.
set dd=%date%
set cc=!dd:~0,2!
:: here i should have created/assigned a new var.
:: but it works so i'll leave it as is
set dd=!%cc%!

i can't testrun the batchfiles on the same computer that i use to access the internet, so my "stuff" often gets garbled in the betwixt.

Report •

December 6, 2009 at 13:45:41
A batch scripting only solution. It is only for use where the date format is 'ddd mm/dd/yyyy' and is not fully tested.

@echo off

:: Convert short day to long day..

if /I "%date:~0,1%" equ "S" if /I "%date:~0,3%" equ "Sun" (
   set day=Sunday&& goto month
   ) else (
   set day=Saturday&& goto month

if /I "%date:~0,1%" equ "T" if /I "%date:~0,3%" equ "Tue" (
   set day=Tuesday&& goto month
   ) else (
   set day=Thursday&&goto month

if /i "%date:~0,3%" equ "Mon" set day=Monday&& goto month
if /i "%date:~0,3%" equ "Wed" set day=Wednesday&& goto month
if /i "%date:~0,3%" equ "Fri" set day=Friday

:: Convert numeric month to alpha-month..

set Monthalpha=January February March April May June July August ^
September October November December

set Monthnumeric=%date:~4,2%
if %Monthnumeric% lss 10 set /a Monthnumeric =1%monthnumeric%-100

for /f "tokens=%Monthnumeric%" %%# in ("%Monthalpha%") do (
    set Month=%%#

:: Display result..
echo.&echo.&echo.      Today's date is %day% %date:~7,2% %Month% %date:~-4%

Report •

December 6, 2009 at 16:55:50
WAY TO GO!!!! Thanks for the help all...both worked after the changes to the first. I knew what needed to be done, but I just could not put the pieces together...

Thanks again for putting that puzzle in place!!

Report •

December 9, 2009 at 10:55:17
I need to format the date (2009-01-01) in the following ways which am mentioning below:
090101, 200911 and 2009011

Could you please help?
I need to create/schedule a batch file to get a file with the above date formats from FTP.


Report •

December 9, 2009 at 11:19:20

I suggest starting your own thread, that way you will get notification emails and the op won't.

Batch Variable how to

Report •

Ask Question