![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
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 Last edited by Jabo; Apr 18th, 2008 at 11:34 PM. |
|
|
|
|
|
#2 |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,011
Rep Power: 5
![]() |
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:
C# Syntax (Toggle Plain Text)
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
#3 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
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. |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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. |
|
|
|
|
|
#5 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
Re: Command line date math
It's gonna take some time for me to learn scripting; in the mean time, I am doing batches.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems with Date objects | sackarias | Visual Basic .NET | 2 | Jan 9th, 2008 12:46 PM |
| Date Routine | tbohon | Perl | 2 | Jan 15th, 2007 11:14 AM |
| Computer Science Prereqs - Math | bigguy | Coder's Corner Lounge | 22 | Mar 15th, 2006 12:19 AM |
| Math Games | Sane | Coder's Corner Lounge | 8 | Dec 22nd, 2005 3:30 AM |
| Recommended math book to accompany course? | Jessehk | Coder's Corner Lounge | 7 | Nov 15th, 2005 6:05 PM |