![]() |
Command line date math
Can anyone point me somewhere or help me with date manipulation from a command prompt. I've searched for a couple of days and I'm not finding anything helpful. What I'm trying to do is manipulate the %date% to reflect the day before. I've tried %date-1:~7,2%, %date:~7,2%-1, %date:~7,2,-1%.
I'm taking it this is not possible, and the value will have to be put into a variable before I can manipulate it. Thing is, this means I'm going to have to put in a whole slew of date checking programming to make sure the date is valid just to do a simple batch file. If anybody has a tip or website, please let me know. This is for a WinXP machine btw |
Re: Command line date math
What exactly is it you need this for? It sounds to me like you will need to use an actual programming language; using (for example) C# makes it pretty easy:
:
|
Re: Command line date math
Actually, getting the information to my batch file is easy using echo to create an FTP script file. Every day we have data generated on our servers, and some of this information is generated for the day before. What I'm doing is grabbing the files and moving them to a backup location, but so far I've only been able to create batch files that grab the files for today's date, not yesterday's. The date is in the file names, and I'm trying to create a script from within my batch file to get those files with yesterday's date, but the %date% function doesn't seem to want to do date math, in other words, %date-1% or whatever. It should be easy to do this with a programming language, but I've read there is very little you can't do from the command line that you can do from a programming language. So, therefor, if it can be done with command line, I'm all for it.
Besides, I've tried to start a program that does FTP, and it's pretty complicated from what I've read about it in VB 2005. Not as simple as using the FTP that is included in windows. I don't want to create a complete FTP just to do a simple task that might go away in a week or a month. EDIT: I guess I could use a shell command to do the FTP part and then do the math in a VB program, then another shell FTP to move the files to the destination. |
Re: Command line date math
Why use a batch file when you could use all manner of other scripting languages and compile them into an EXE, which can be run anywhere?
You can do a lot of complicated stuff with a batch file. Whether it's worth doing, I'm not so sure. Even Microsoft seem to have abandoned the idea with the Windows PowerShell. |
Re: Command line date math
It's gonna take some time for me to learn scripting; in the mean time, I am doing batches.
|
| All times are GMT -5. The time now is 6:19 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC