Computing.Net > Forums > Disk Operating System > get TIME & DATE into var

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.

get TIME & DATE into var

Reply to Message Icon

Name: Mechanix2Go
Date: March 4, 2005 at 11:41:45 Pacific
OS: w2k
CPU/Ram: PIII 933 / 256
Comment:

Here's a challenge for you.

Get TIME & DATE into env vars using only DOS internal commands.

No DEBUG; no FIND; no SORT.

Yes, real DOS.

5.0 and up.

Any strugglers out there?

M2



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: March 4, 2005 at 13:00:38 Pacific
Reply:

Hi Mechanix2Go,

are you in the mood of kidding? Well, I set the date only and, as I am Italian and I do not have an English edition of DOS on hand, let us assume the output of the Date command be

Current date is Mon yyyy-dd-mm
Enter the new date:

So assumed your code is

@Echo Off
Echo. | Date > X.bat
Echo @Set MyDate= %3 %4> Current.bat
X

and you are done. Anyone to complete the exercise?


0

Response Number 2
Name: jboy
Date: March 4, 2005 at 13:27:49 Pacific
Reply:

Plenty of variations on a theme at this site

You are here


0

Response Number 3
Name: Dan Penny
Date: March 4, 2005 at 15:05:48 Pacific
Reply:

Here is another site. (Secret Doom)


0

Response Number 4
Name: jboy
Date: March 4, 2005 at 17:23:11 Pacific
Reply:

Different URL, same page - the ways of Secret_Doom are not for us to question ; )

You are here


0

Response Number 5
Name: Dan Penny
Date: March 4, 2005 at 17:59:49 Pacific
Reply:

Son of a gun. A fast glance at the address told me it was different so I posted the one I had. Sorry, I ~should~ have gone to the site (your post) to check it. ;>{


0

Related Posts

See More



Response Number 6
Name: dtech10
Date: March 5, 2005 at 15:29:58 Pacific
Reply:

This causes three Commands not found errors.
buts worked in Dos5.
the "dir abc123.bat > abc1234.bat" could be changed to "dir abc123.bat | find "ABC123" > abc1234.bat" to stop these errors.

@echo off
rem Sets XDATE & XTime environment varables
echo @echo off > abc123.bat
echo set XDATE=%%3 >> abc123.bat
echo set XTIME=%%4 >> abc123.bat
dir abc123.bat > abc1234.bat
call abc1234.bat
del abc123.bat > nul
del abc1234.bat > nul


0

Response Number 7
Name: jboy
Date: March 5, 2005 at 16:18:58 Pacific
Reply:

"This causes three Commands not found errors"

??



0

Response Number 8
Name: dtech10
Date: March 5, 2005 at 16:34:55 Pacific
Reply:

Hi JBoy
I said that it did ,but these could be stopped by the Find commannd above.



0

Response Number 9
Name: jboy
Date: March 5, 2005 at 17:08:02 Pacific
Reply:

That exact error is unfamiliar to me - but the idea behind decent batching is not to generate error messages. At best it's... inelegant.



0

Response Number 10
Name: Mechanix2Go
Date: March 6, 2005 at 23:30:09 Pacific
Reply:

Hi gang,

I knew many of you could do this easily.

Especially IVO.

;)

dtech10, thanks for that. I'm looking it over know.

More later

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon






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: get TIME & DATE into var

Date output to variable. Scheduler www.computing.net/answers/dos/date-output-to-variable-scheduler/15566.html

Date into a variable, with 2 digit year! www.computing.net/answers/dos/date-into-a-variable-with-2-digit-year/11289.html

Putting date into filename www.computing.net/answers/dos/putting-date-into-filename/13267.html