View Full Version : Help with a Time script


ajmister
02-25-2004, 08:29 AM
Hi

If I run the following command before noon (9 am) set
filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
it gives me 20040225_ 901. if I run after noon (3:15 pm) it gives me
20040225_1515. Is there away to include the 0 before the _ 901 time stamp.

Does some one have a solution.

Thank you
Ajay

ajmister
02-25-2004, 09:10 AM
Thank you.

Ajay
"Phil Robyn [MVP]" <zipprobyn@berkeley.edu> wrote in message
news:ORlXnM##DHA.3500@TK2MSFTNGP10.phx.gbl...
> ajmister wrote:
>
> > Hi
> >
> > If I run the following command before noon (9 am) set
> > filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
> > it gives me 20040225_ 901. if I run after noon (3:15 pm) it gives me
> > 20040225_1515. Is there away to include the 0 before the _ 901 time
stamp.
> >
> > Does some one have a solution.
> >
> > Thank you
> > Ajay
> >
> >
>
> filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
> set filename=%filename: =0%
>
>
> --
> Phil Robyn
> Univ. of California, Berkeley
>
> u n z i p m y a d d r e s s t o s e n d e - m a i l

ajmister
02-25-2004, 09:10 AM
Thank you.

Ajay
"Phil Robyn [MVP]" <zipprobyn@berkeley.edu> wrote in message
news:ORlXnM##DHA.3500@TK2MSFTNGP10.phx.gbl...
> ajmister wrote:
>
> > Hi
> >
> > If I run the following command before noon (9 am) set
> > filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
> > it gives me 20040225_ 901. if I run after noon (3:15 pm) it gives me
> > 20040225_1515. Is there away to include the 0 before the _ 901 time
stamp.
> >
> > Does some one have a solution.
> >
> > Thank you
> > Ajay
> >
> >
>
> filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
> set filename=%filename: =0%
>
>
> --
> Phil Robyn
> Univ. of California, Berkeley
>
> u n z i p m y a d d r e s s t o s e n d e - m a i l

wadester
02-25-2004, 09:04 PM
In article <OWg9M49#DHA.1700@TK2MSFTNGP12.phx.gbl>,
ajmister@optonline.net wrote...
> Hi
>
> If I run the following command before noon (9 am) set
> filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
> it gives me 20040225_ 901. if I run after noon (3:15 pm) it gives me
> 20040225_1515. Is there away to include the 0 before the _ 901 time stamp.
>
> Does some one have a solution.

How about:

REM replace any spaces in %TIME% with 0 (should only occur at the
left-most position)
set fulltime=%time: =0%
set filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%fulltime:~0,2%%
fullime:~3,2%

ws

--
The sea was angry that day, my friends. Like an old man, trying to
send back soup at a deli.

wadester
02-25-2004, 09:04 PM
In article <OWg9M49#DHA.1700@TK2MSFTNGP12.phx.gbl>,
ajmister@optonline.net wrote...
> Hi
>
> If I run the following command before noon (9 am) set
> filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
> it gives me 20040225_ 901. if I run after noon (3:15 pm) it gives me
> 20040225_1515. Is there away to include the 0 before the _ 901 time stamp.
>
> Does some one have a solution.

How about:

REM replace any spaces in %TIME% with 0 (should only occur at the
left-most position)
set fulltime=%time: =0%
set filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%fulltime:~0,2%%
fullime:~3,2%

ws

--
The sea was angry that day, my friends. Like an old man, trying to
send back soup at a deli.

Phil Robyn [MVP]
02-25-2004, 09:05 PM
ajmister wrote:

> Hi
>
> If I run the following command before noon (9 am) set
> filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
> it gives me 20040225_ 901. if I run after noon (3:15 pm) it gives me
> 20040225_1515. Is there away to include the 0 before the _ 901 time stamp.
>
> Does some one have a solution.
>
> Thank you
> Ajay
>
>

filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
set filename=%filename: =0%


--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l

Phil Robyn [MVP]
02-25-2004, 09:05 PM
ajmister wrote:

> Hi
>
> If I run the following command before noon (9 am) set
> filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
> it gives me 20040225_ 901. if I run after noon (3:15 pm) it gives me
> 20040225_1515. Is there away to include the 0 before the _ 901 time stamp.
>
> Does some one have a solution.
>
> Thank you
> Ajay
>
>

filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,2%
set filename=%filename: =0%


--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l

Mark V
02-25-2004, 11:56 PM
In microsoft.public.win2000.cmdprompt.admin ajmister wrote:

> Hi
>
> If I run the following command before noon (9 am) set
> filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,
> 2% it gives me 20040225_ 901. if I run after noon (3:15 pm) it
> gives me 20040225_1515. Is there away to include the 0 before the
> _ 901 time stamp.

One solution is to change the "International Settings" (Regional
settings) for Date and Time Format for the account or system you are
using. If that is feasible and desired of course.

2004-02-25 18:56:46

Mark V
02-25-2004, 11:56 PM
In microsoft.public.win2000.cmdprompt.admin ajmister wrote:

> Hi
>
> If I run the following command before noon (9 am) set
> filename=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%_%Time:~0,2%%Time:~3,
> 2% it gives me 20040225_ 901. if I run after noon (3:15 pm) it
> gives me 20040225_1515. Is there away to include the 0 before the
> _ 901 time stamp.

One solution is to change the "International Settings" (Regional
settings) for Date and Time Format for the account or system you are
using. If that is feasible and desired of course.

2004-02-25 18:56:46