Jump to content

Creating a batch file that input date & time


gpm1968

Recommended Posts

Hi

I create my logo and assign a job for each XP install I do. My job number takes the date and time of the day I am working on a piece. eg 200403242038 and this never repeats. Now how can i create a batch file that can automatically assign the date and time so that i can generate this job number

:)

Link to comment
Share on other sites


On the cmd when I type Date i get " the current date is *****" " enter new date

the same thing for time. Now I want to capture these parameters ( date and time) so that i can use the generated date and time in my answer file. is it possible

gpm

Link to comment
Share on other sites

thanks iam getting somewhere now - is it possible to craete an output file with date and time in one line, why because I want it that way to create a job # for my logo. I use a program called wintrieve to create the logo and put support info

gpm

Link to comment
Share on other sites

Dim obj, strA
Set obj = CreateObject("Scripting.FileSystemObject")
Set strA = obj.CreateTextFile("datetime.txt", True)
strA.write(now())
strA.Close
Set obj = Nothing

Save that as Datetime.vbs and just run it. It will create the file in same Dir

You can change this to whatever you want "datetime.txt" like "C:\App\datetime.txt"

Link to comment
Share on other sites

Windows has 2 variables for this. One is %time% and other is %date%. You can try them by typing

echo %time%

or

echo %date%

into the comamnd line. I would use it as:

copy backup.rar "%date%backup.rar"

Link to comment
Share on other sites

,Mar 27 2004, 12:06 PM]Windows has 2 variables for this. One is %time% and other is %date%. You can try them by typing
echo %time%

or

echo %date%

into the comamnd line. I would use it as:

copy backup.rar "%date%backup.rar"

There "/" and ":", this cannot work!

You should reformat it:

echo %date:/=-% %time::=_%

Link to comment
Share on other sites

set x=%date:/=-%.%time::=_%
set x=%x: =0%
echo %x:~0,19%

=> 29-03-2004.08_01_29

See SET/? and FOR/? to see all the possiilities, so you will be able to reverse the date to have yyyy-mm-dd.

To have YYMMDD:

set x=%date%
set yy=%x:~8,2%
set mm=%x:~3,2%
set dd=%x:~0,2%
echo %yy%%mm%%dd%

Edited by mdes
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...