how to get current date and time in command line

Posted by Ieyasu Sawada on Stack Overflow See other posts from Stack Overflow or by Ieyasu Sawada
Published on 2010-12-25T09:14:55Z Indexed on 2010/12/25 9:54 UTC
Read the original article Hit count: 249

Filed under:
|
|

I am using mysqldump to backup mysql database. Now I just need to use the current date and time as file name for the generated sql file. How do I do that if my current code looks like this:

mysqldump -u root -p --add-drop-table --create-options --password= onstor >c:\sql.sql

I also found this code from this site, but I do not know how to incorporate it in my current code:

@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
echo %mydate%_%mytime%

Please help, thanks:)

© Stack Overflow or respective owner

Related posts about mysql

Related posts about automation