gpm1968 Posted March 25, 2004 Share Posted March 25, 2004 HiI 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 More sharing options...
likuidkewl Posted March 25, 2004 Share Posted March 25, 2004 http://www.myitforum.com/articles/11/view.asp?id=2750 Link to comment Share on other sites More sharing options...
gpm1968 Posted March 25, 2004 Author Share Posted March 25, 2004 On the cmd when I type Date i get " the current date is *****" " enter new datethe 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 possiblegpm Link to comment Share on other sites More sharing options...
Shotgun Posted March 25, 2004 Share Posted March 25, 2004 This works for Windows NT and up:DATE /T outputs the current dateTIME /T outputs the current time Link to comment Share on other sites More sharing options...
Shotgun Posted March 25, 2004 Share Posted March 25, 2004 Forgot to mention that the output from DATE and TIME can be redirected to another program or to a file. Link to comment Share on other sites More sharing options...
gpm1968 Posted March 27, 2004 Author Share Posted March 27, 2004 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 infogpm Link to comment Share on other sites More sharing options...
maxXPsoft Posted March 27, 2004 Share Posted March 27, 2004 Dim obj, strASet obj = CreateObject("Scripting.FileSystemObject")Set strA = obj.CreateTextFile("datetime.txt", True)strA.write(now())strA.CloseSet obj = NothingSave that as Datetime.vbs and just run it. It will create the file in same DirYou can change this to whatever you want "datetime.txt" like "C:\App\datetime.txt" Link to comment Share on other sites More sharing options...
Matri[X] Posted March 27, 2004 Share Posted March 27, 2004 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 More sharing options...
mdes Posted March 27, 2004 Share Posted March 27, 2004 ,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 More sharing options...
gpm1968 Posted March 29, 2004 Author Share Posted March 29, 2004 mdes you are the man thanks a lot - is it possible to take off the spacers28-03-2004 21_*GPM Link to comment Share on other sites More sharing options...
mdes Posted March 29, 2004 Share Posted March 29, 2004 (edited) set x=%date:/=-%.%time::=_%set x=%x: =0%echo %x:~0,19%=> 29-03-2004.08_01_29See 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 April 9, 2004 by mdes Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now