Reposting this as I got a rejected from the list but I don't think I sent it previously:
I think this works in NT4 and W2K:
FOR /f "tokens=1-4 delims=/ " %a in (DATE/T) do (set day=%a&set mmonth=%b&set dd=%c&set year=%d&set /a pd=%%c-1)
this will result in:
day=Tue
mmonth =05
dd=21
year=2002
pd=20
of course, pd will only work for days other than the 1st of the month...
I have a bat file that someone else wrote that looks like it will run through commands to set the pd correctly if someone wants it....
BTW: I did not come up with this. I had it in an example from another bat file and tried it on my NT4 server and it worked.... :-)
bob
On Tuesday, May 21, 2002 1:27 PM, Arthur Frank <[log in to unmask]> wrote:
>"Windows NT Shell Scripting" by Tim Hill is a wonderful resource
>that covers all of this stuff. On Amazon (watch the wrap):
>http://www.amazon.com/exec/obidos/ASIN/1578700477/ref=pd_ecc_rvi_2/104-5091672-0946362
>Scripting for the NT shell is pretty cool, but it is *so*
>limited when compared to MPE CI scripting.
>
>I've been watching this thread closely, because I've wanted to
>do the same thing, and the %DATE% variable is NOT available in
>Windows NT 4, though it is available in 2000. Tom Emerson
>posted an elaborate bit of code that might do what I need, but
>I haven't tried it out yet...
>
>Art Frank
>Manager of Information Systems
>OHSU Foundation
>[log in to unmask]
>(503) 220-8320
>
>>>> Tracy Pierce <[log in to unmask]> 05/21/02 11:37AM >>>
>http://users.cybercity.dk/~bse26236/batutil/help/INDEX.HTM#s
>is pretty good; it's on google's first page of results for "MS-DOS". I
>didn't find specific reference to the string handling squiggle bit, but
>didn't look very hard.
>
>> -----Original Message-----
>> From: [log in to unmask] [mailto:[log in to unmask]]
>> Sent: Tuesday, May 21, 2002 11:33 AM
>> To: [log in to unmask]
>> Subject: Re: OT: M$-Dos Question
>>
>>
>> Well, that's interesting. I'm familiar with some rather old,
>> kludgy ways of
>> performing very crude date / time logic. This NTism is new to
>> me. So are the
>> offsets into the strings. Issuing SET to display env vars
>> does not list
>> this. And, I cannot find it in W2K help. And, neither google nor
>> microsoft.com seem to be able to do much with % in strings.
>> If anyone can
>> point me to some documentation on these env vars and related NT / W2K
>> features, I would welcome it.
>>
>> > -----Original Message-----
>> > From: Bob McGregor [mailto:[log in to unmask]]
>> > Sent: Tuesday, May 21, 2002 10:19 AM
>> > To: [log in to unmask]
>> > Subject: Re: OT: M$-Dos Question
>> >
>> > set yyy=%DATE%
>> > or to get the month value only
>> > set yyy=%DATE:~4,2%
>>
>
>* To join/leave the list, search archives, change list settings, *
>* etc., please visit
>http://raven.utc.edu/archives/hp3000-l.html *
>
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|