I'm trying to write a cmd script that gets the current date and time and formats it into a way that sqlserver can input it as a datetime
.
So far, I have:
@echo off
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set dow=%%i
set mon=%%j
set day=%%k
set yr=%%l
set mydate=%%j/%%k/%%l
)
This prints out 10/22/2010
I have not been able to figure out how to get the time into a usable format. I tried working with time /t
, but it only gives the hours and minutes, and I need the seconds also.