formatiing date regardless of regional options (again)

  • Thread starter Thread starter BigMan
  • Start date Start date
B

BigMan

There was a topic here dealing with the issue of formatiing a date in the
format yyyy-mm-dd with a VB script. Could you please post the source again.
 
BigMan said:
There was a topic here dealing with the issue of formatiing a date in the
format yyyy-mm-dd with a VB script. Could you please post the source again.

Your complaining about a pm from jerold makes your pseudonym
look curious.

You did already hear of google ?
http://groups.google.com/groups?q=group:microsoft.public.win2000.cmdprompt.admin+wscript+date

The last one from Torgeir Bakken:
http://groups.google.com/[email protected]

--------------------8<----------------------
@echo off
echo D = Now : WScript.Echo Year(D) ^& "-" ^& _ >%tmp%\today.vbs
echo Right(100+Month(D),2) ^& "-" ^& Right(100+Day(D),2) >>%tmp%\today.vbs

for /f "tokens=1" %%a in (
'cscript.exe //Nologo %tmp%\today.vbs') do set today=%%a

del %tmp%\today.vbs
echo Todays date: %today%
--------------------8<----------------------
 
BigMan said:
I need a solution with vbscript. And please, do not reply by e-mail!
Hi

Actually, Jerold's tip 8600 *is* using vbscript and will always give
the same formatting regardless of regional options settings, see the
callout to cscript.exe in the batch file:

http://www.jsiinc.com/SUBR/tip8600/rh8600.htm


The code is in this tip is based on code I have posted previously in
this newsgroup, Jerold have just combined/evolved it a bit more.
 
BigMan said:
There was a topic here dealing with the issue of formatiing a date in the
format yyyy-mm-dd with a VB script. Could you please post the source again.

In addition to these answers, I wrote a freeware tool called datex.exe
that lets you output a date in various formats and it also lets you
specify a number-of-days offset.

datex -f y-mm-dd

This will output today's date in the format
4digityear-twodigitmonth-twodigitday. You could use FOR /F to capture to
an environment variable:

for /f "delims=" %%d in ('datex -f y-mm-dd') do set TODAY=%%d

You can download the bst11.zip package here:

http://www.cybermesa.com/~bstewart/bst.html
 
Back
Top