[dos] yesterday's date

Gaetan -  
dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   -
Bonjour,
I am currently setting up a file renaming batch in DOS and I need to retrieve yesterday's date in the filename (so something like getdate()-1).

PS: I can already retrieve the date into a variable and format it (e.g., filename_21112006.xls)

If someone can help me out of this deadlock, that would be great.
Thank you in advance.

1 answer

Bernard.Mouille
 
Good evening Gaetan,

I'm also interested in the question of an earlier date as some of my applications use it.

I've solved the problem, but the solution I have is heavy.

If someone had a lighter solution, that would be wonderful.

If you want my (heavy) solution, I can send it to you.

Have a good evening

B.M.
0
Edouard
 
Hi,

I'm open to any solution, including heavy ones...

Edouard
0
Bernard.Mouille > Edouard
 
Good evening Edouard

You can take the compressed file which contains:

an execution BAT file for example,
a DOS EXE file (it's CLIPPER)

Make sure there are no viruses

http://perso.orange.fr/bernard.mouille/dateav/DATEAV.ZIP

Let me know what you think

Good night

BM
0
Bernard.Mouille > Edouard
 
Good evening Edouard


My apologies for the delay, but I wasn't notified by email because you created a new discussion topic.

The source of the exe program follows: it's Clipper5

Have a nice day

Bernard

------------------PRG File ----------------------


* DATEAV.PRG - Retrieve a different date.
* -------------------------------------------
*
PARAMETERS DATEX
*
IF PCOUNT()==0
DATEX=-1
ELSE
DATEX=VAL(DATEX)
ENDIF
*
SET DATE FREN
SET CENT ON
XF=FCREATE("DATEAV.TXT",0)
FWRITE(XF,DTOC(DATE()+DATEX))
FCLOSE(XF)
RETU


----------------- Bat File --------------------

@ REM Parameter to pass: the number of days as positive or
@ REM negative: -15 or 15 for example.
@ REM No parameter = -1 by default.
@
@ DATEAV.EXE -15
@
@
@ DATE >DATEJO.TXT /T
@ ECHO Today's date: %DATE%
@ DATE<DATEAV.TXT
@ ECHO Yesterday's date: %DATE%
@ DATE<DATEJO.TXT
@ ECHO Today's date: %DATE%
@ DEL DATEJO.TXT >NUL
@ DEL DATEAV.TXT >NUL
@ PAUSE
0
EDOUARD > Bernard.Mouille
 
Hi Bernard,

Thanks for the clipper code, it will surely be useful to someone.

Otherwise, I just got your exe to work by generating a J-1 date in one txt and a J-8 date in another.

Then I retrieve my dates and present them to the anglosaxon with For tokens...

Then I delete the txt files.

Anyway, it's cumbersome but it works "like clockwork".

And the goal is just to make a daily call to this batch with a scheduled task and call a php script with the right dates, so the processing wasn't very heavy either.

Anyway, as often, the result is what matters (to me) and not the method...
0
dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 659 > Bernard.Mouille
 
Hello,
install the GNU/Linux date command and type date yesterday

http://unxutils.sourceforge.net/
0