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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Date into a variable, with 2 digit year!

Reply to Message Icon

Name: Andrew P
Date: August 22, 2002 at 19:43:20 Pacific
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 --



Sponsored Link
Ads by Google

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

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.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Date into a variable, with 2 digit year!

date Value in a variable in format www.computing.net/answers/dos/date-value-in-a-variable-in-format-/13474.html

Date environmental variable www.computing.net/answers/dos/date-environmental-variable/12539.html

Copying files-date as a parameter www.computing.net/answers/dos/copying-filesdate-as-a-parameter/12916.html