Logs Named By Current DateTime

I have a scheduled task and I’d like to save logs from the output. After some quick batch file work, I came up with this.

@echo off

for /f "tokens=2" %%A in ('date /t') DO @(set MyDate=%%A)
set MyDate=%MyDate:/=-%

set MyTime=%TIME::=-%
set MyTime=%MyTime:.=-%
set MyFilename=%MyDate%_%MyTime%.log

echo Writing output to %MyFilename%
mytask.exe > %MyFilename%


I end up with filenames like 10-02-2009_14-34-56-00.log which gets the point across. Do you have a better way to accomplish this?