1.

Solve : How to force a particular dateFormat for batch.?

Answer»

Hi there:
Is there a MS-DOS command which I can insert into my batch file for
specifying a particular date format to be used during my batch
execution?

The format I would like to use in my batch execution is like this:
Sun 2006/06/25

Currently it defaults to 2006/06/25 (i.e the short date as
pre-specified in my "Regional and Language Options"). But what I would
like to ACHIEVE here is to force a particular date format regardless of
what the "Regional and Language Options" says).

APPRECIATE your help.

Regards,
-David-

So you dont want current date or time? If you want a set date why dont you just echo the date? If you want the current date put

Code: [Select]current date: %date%Hi [emailprotected]:
Thanks for getting back to me.

You are RIGHT, I don"t want the %Date%, as it returns a date format that is not friendly to my batch exe. A %Date% entered on my workstation (running on MS Windows XP Pro) would return a date format of "2006/06/26", but my batch file expects it to return a format of "Mon 2006/06/26" instead.

Here's my batch code:

REM This batch file assumes a standard workstation date format of
rem dayOfWeek yyyy/mm/dd.

for /F "tokens=1-4 delims=/-. " %%i in ('date /t') do (
set DOW=%%i
set MM=%%k
set DD=%%l
set YYYY=%%j
set FDate=%%i %%j/%%k/%%l
set ymd_dt=%%j%%k%%l
set ymd=%%j%%k%%l
set ymd_fmt=%%j/%%k/%%l
)

@echo.
@echo hello David!
@echo This batch file assumes a standard workstation date format of
@echo dayOfWeek yyyy/mm/dd (eg. Sun 2006/06/25)

@echo.
@ECHO Date is %Date%
@ECHO Day of Week is "%DOW%"
@echo Month is "%MM%"
@ECHO Day is "%DD%"
@echo Year is "%YYYY%"
@echo fdate is "%fdate%"
@echo ymd_dt is "%ymd_dt%"
@echo ymd is "%ymd%"
@echo ymd_fmt is "%ymd_fmt%"
@echo.

pause ** press any key to continue **

:finish

A command or something to pre-specify the dateFormat used in an execution would certainly help.
Any thoughts?

Regards,
David.check out this site
http://www.commandline.co.uk/lib/



Discussion

No Comment Found