MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: Delayed Expansion (in loops)[Next]: Get File Safe Dates and Times
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->Batch Files->Batch File Tips and Tricks->Get Day, Month, and Year

Get Day, Month, and Year

The following works for both "dd/mm/yyyy" and "mm/dd/yyyy":

@echo off
@rem NEWSGROUP: microsoft.public.win2000.cmdprompt.admin
@rem SUBJECT  : How can i to get the current month in commandline?
@rem WHEN/WHO : Mar 14 2001, 9:05 pm  post by Michael (maj0)

:: Tokenise date into dd mm and yy independent of locale
for /f "tokens=2-4 delims=.:/-, " %%i in ("%date%") do (
  for /f "tokens=2-4 delims=/-,() skip=1" %%l in ('echo.^|date') do (
    set %%l=%%i
    set %%m=%%j
    set %%n=%%k))


:: Lets see what we got!
for %%i in (dd mm yy) do set %%i

You may also wish to have a look at the "Get File Safe Dates and Times" section.


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Delayed Expansion (in loops)[Next]: Get File Safe Dates and Times


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday May 28 2022 at 3:11pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.