Computing.Net > Forums > Disk Operating System > Date into a variable, with 2 digit year!

Date into a variable, with 2 digit year!

Reply to Message Icon

Original Message
Name: Andrew P
Date: August 22, 2002 at 19:43:20 Pacific
Subject: Date into a variable, with 2 digit year!
Comment:

People,
Basically firstly want to say cheers to Leonardo (aka Secret_doom) for helping me out with this one. So much help and solved a big headache for me! I owe him a beer!
I used one of his batch scripts to pass the current date into a variable, but I required a 2 digit year (as the files I was trying to get had a 2 digit year (ie 02).
Below is the script and the fix, so that anyone else who needs to sort this one out can do so too.
Again thanks go to Leonardo...Everyone else, go to www.batch.hpg.com.br for some top batch file stuff !!

Hello, Andrew.

Saw the site BTW...very good. Like it alot,
and helped me out a few times.

It's good to hear that.

About the batch file, modify this line:

for %%? in (e10D''3B e110''3B w q) do echo %%?>> %TEMP%.\T2.DAT

By this:

for %%? in (e10D''3B f110L3''3B w q) do echo %%?>> %TEMP%.\T2.DAT

And it's done! Here's the modifyed batch file (maybe a little bit different from the one you've got, I've updated that FAQ yesterday):

:: Get current date into variable without separators
@echo off
echo.EXIT|%COMSPEC%/K PROMPT SET %%1=$D$_|FIND " "> %TEMP%.\T1.BAT
type nul> %TEMP%.\T2.DAT
for %%? in (e10D''3B f110L3''3B w q) do echo %%?>> %TEMP%.\T2.DAT
DEBUG %TEMP%.\T1.BAT nul
call %TEMP%.\T1.BAT CDATE
:: Next line defines date format. The values generally are:
:: %%1=Week day %%2=Month %%3=Date %%4=Year (4 digits)
:: Those could change, depending mainly on the COUNTRY
:: command (from config.sys).
echo SET CDATE=%%4%%2%%3> %TEMP%.\T1.BAT
call %TEMP%.\T1.BAT %CDATE%
for %%? in (T1.BAT T2.DAT) do del %TEMP%.\%%?
echo CDATE=%CDATE%

Im using MS DOS 6.22 if thats any help.

Yes, that's of much help =D

-- Leonardo Pignataro - Secret_Doom --


Report Offensive Message For Removal


Response Number 1
Name: dtech10
Date: August 26, 2002 at 17:06:00 Pacific
Reply: (edit)

Hi
with dos6 the dir command gives 2 digit years I believe something like this 12-10-02
it this is what you wanted. if so I post or email you will a more simpler batch file code to put the date and time into variables, no dis-respect to Secret_Doom method.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Date into a variable, with 2 digit year!

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge