batch file Subtracting hour current time on Windows
<p>I need to subtract, for example, 1 hour from current time in a .bat file on Windows 7.</p>

<p>I do it like this.</p>

<pre><code>set day=%date:~0,2%
set month=%date:~-7,2%
set year=%date:~-4,4%
:: ———————————————————————–
set hour=%time:~0,2%

set /A hour= hour - 1

if %hour% lss 0 set hour=23
if %hour% lss 10 set hour=0%hour%

echo %year%-%month%-%day% %hour%:00
</code></pre>

<p>But the problem, it is get consistence when the subtracting results a day before on a month before. For example, this date, <strong>2016-03-01 00:05</strong> I get <strong>2016-03-01 23:05</strong>. I need to get <strong>2016-02-29 23:05</strong></p>

<p>I found several batch script to subtract one day, but nothing with hours or minutes.</p>