Why do people make this so hard? I see huge scripts on the internet dedicated to just this topic of parsing the date. Here, it’s this simple:
First, let’s look what date looks like in DOS:
With that in mind, you can also use the built-in %DATE% variable:
Now that we have this information, let’s look at how to simplify this and come up with whatever format we want to display the date in…
String substitution; Read more about it here: DosTips
So you have replaced something like this:
@For /F tokens=1,2,3 delims=. %%A in ('Date /t') do @(
@echo DAY = %Day%
@echo Month = %Month%
@echo Year = %Year%
With a single, simple, line!
If you want to experiment further, try using
%TIME% too. I use
%TIME% in my backup/compression batch scripts for pre/post backup solutions in many cases and also for log files. Works like a champ.