using sortable date as parameter without typing the date

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Norma
Posts: 5
Joined: 22 May 2020 18:27

using sortable date as parameter without typing the date

#1 Post by Norma » 22 May 2020 18:34

I have a number of batch files that use the current date, in yyyymmdd format, as a parameter. Is there an alternative to having to key in the date a digit at a time when I run the batch file?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: using sortable date as parameter without typing the date

#2 Post by aGerman » 24 May 2020 04:14

Code: Select all

@echo off &setlocal
for /f %%i in ('WMIC OS Get LocalDateTime /value') do for /f %%j in ("%%i") do set "%%j"
set "d=%LocalDateTime:~,8%"
:: echo %d%
:: pause
call "yourScript.bat" %d%
There are two lines commented out, where you can check if %d% contains the today's date string. The last line shows how to pass it to the first parameter of your script.

Steffen

Norma
Posts: 5
Joined: 22 May 2020 18:27

Re: using sortable date as parameter without typing the date

#3 Post by Norma » 24 May 2020 07:17

Thank you!

Post Reply