%Date% returns different values....

This is a discussion on %Date% returns different values.... within the MS-DOS forums, part of the Other OS category; I posted this over in a windows server group and it was recommended that I pop over here. Does anyone have any ideas? It appears to be profile based to ...

Go Back   Unix Linux Forum > Unix > Other OS > MS-DOS

FixUnix.com - Unix Linux Forums

Unix Content Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-26-2008, 04:26 PM
Default %Date% returns different values....

I posted this over in a windows server group and it was recommended
that I pop over here. Does anyone have any ideas? It appears to be
profile based to me as I see in my logs two uses logging into the same
Terminal Server with the two values. I just need to try and figure out
the best way (albeit manual if need be) to get all the dates the same.
Thanks.


.......Original Post here.....
I have what I thought would be a simple project that is stumping me
at
the moment. I was asked to create a simple login/out file to log when
a user signs in and out of a machine. I set up the script shown here:

echo %COMPUTERNAME%, %USERNAME%, %date%, %TIME%, Login >> \
\mopssrv01\MISData\MOPS-LOGONS.csv


Simple one line bat file that I put in as a Login Script through GP.
I
have another one for Logout with just the word change at the end to
tell me what they were doing.


This is the output that I get in my CSV. Note the first and last one
has the MON as part of the date. I have looked around and must be
totally blind as I dont' see where I can change the actual format of
the date to get two different values for %date%. Any ideas/thoughts?


WKSTN0027 USER1 Mon 08/25/2008 9:04:02.45 Login
WKSTN0014 USER2 08/25/2008 9:05:19.57 Login
WKSTN0033 USER3 08/25/2008 9:05:21.96 Login
WKSTN0021 USER4 Mon 08/25/2008 9:07:03.16 LogOut


Not that it would really matter, but I did change the names from the
real users!


TIA.
Tim

Reply With Quote
  #2  
Old 08-26-2008, 05:09 PM
Default Re: %Date% returns different values....

TimParker wrote:
> This is the output that I get in my CSV. Note the first and last one
> has the MON as part of the date. I have looked around and must be
> totally blind as I dont' see where I can change the actual format of
> the date to get two different values for %date%. Any ideas/thoughts?


You can't that directly. Getting a (unique) date is one of the most
frequent questions in the group. A unique format can be ascertained, but
not trivially. For more information see e.g.

1} How to get today's date elements into environment variables?
http://www.netikka.net/tsneti/info/tscmd001.htm

165} How do I get the date and time separators and the local formats?
http://www.netikka.net/tsneti/info/tscmd165.htm

> WKSTN0027 USER1 Mon 08/25/2008 9:04:02.45 Login
> WKSTN0014 USER2 08/25/2008 9:05:19.57 Login


Quite probably resolving the complications are not worth one's while,
but it can be done. Especially if VBS is acceptable.


All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:ts@uwasa.fi ; FI-65101, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm
Reply With Quote
  #3  
Old 08-26-2008, 11:47 PM
Default Re: %Date% returns different values....


"TimParker" wrote in message
news:e65305b3-4286-4af2-b486-c0b7feae4dd9@f63g2000hsf.googlegroups.com...
>I posted this over in a windows server group and it was recommended
> that I pop over here. Does anyone have any ideas? It appears to be
> profile based to me as I see in my logs two uses logging into the same
> Terminal Server with the two values. I just need to try and figure out
> the best way (albeit manual if need be) to get all the dates the same.
> Thanks.
>
>
> ......Original Post here.....
> I have what I thought would be a simple project that is stumping me
> at
> the moment. I was asked to create a simple login/out file to log when
> a user signs in and out of a machine. I set up the script shown here:
>
> echo %COMPUTERNAME%, %USERNAME%, %date%, %TIME%, Login >> \
> \mopssrv01\MISData\MOPS-LOGONS.csv
>
>
> Simple one line bat file that I put in as a Login Script through GP.
> I
> have another one for Logout with just the word change at the end to
> tell me what they were doing.
>
>
> This is the output that I get in my CSV. Note the first and last one
> has the MON as part of the date. I have looked around and must be
> totally blind as I dont' see where I can change the actual format of
> the date to get two different values for %date%. Any ideas/thoughts?
>
>
> WKSTN0027 USER1 Mon 08/25/2008 9:04:02.45 Login
> WKSTN0014 USER2 08/25/2008 9:05:19.57 Login
> WKSTN0033 USER3 08/25/2008 9:05:21.96 Login
> WKSTN0021 USER4 Mon 08/25/2008 9:07:03.16 LogOut
>
>
> Not that it would really matter, but I did change the names from the
> real users!
>
>
> TIA.
> Tim
>


Timo's articles certainly show HOW to overcome the problem.

The blindness however isn't on your part - there is no switch available to
produce DATE (or TIME, for that matter) in a universal format. The format
generated is that set as the 'short-format' by the USER, and may change on a
user-by-user basis - hence to provide a universal format, each possible
individual variation of element-presence, element-sequence, separator and
12/24-hour format structure needs to be addressed.


Reply With Quote
  #4  
Old 08-27-2008, 01:02 AM
Default Re: %Date% returns different values....

On Aug 27, 4:26*am, TimParker wrote:
> I posted this over in a windows server group and it was recommended
> that I pop over here. Does anyone have any ideas? It appears to be
> profile based to me as I see in my logs two uses logging into the same
> Terminal Server with the two values. I just need to try and figure out
> the best way (albeit manual if need be) to get all the dates the same.
> Thanks.
>
> ......Original Post here.....
> I have what I thought would be a simple project that is stumping me
> at
> the moment. I was asked to create a simple login/out file to log when
> a user signs in and out of a machine. I set up the script shown here:
>
> echo %COMPUTERNAME%, %USERNAME%, %date%, %TIME%, Login >> \
> \mopssrv01\MISData\MOPS-LOGONS.csv
>
> Simple one line bat file that I put in as a Login Script through GP.
> I
> have another one for Logout with just the word change at the end to
> tell me what they were doing.
>
> This is the output that I get in my CSV. Note the first and last one
> has the MON as part of the date. I have looked around and must be
> totally blind as I dont' see where I can change the actual format of
> the date to get two different values for %date%. Any ideas/thoughts?
>
> WKSTN0027 USER1 Mon 08/25/2008 *9:04:02.45 Login
> WKSTN0014 USER2 08/25/2008 *9:05:19.57 Login
> WKSTN0033 USER3 08/25/2008 *9:05:21.96 Login
> WKSTN0021 USER4 Mon 08/25/2008 *9:07:03.16 LogOut
>
> Not that it would really matter, but I did change the names from the
> real users!
>
> TIA.
> Tim


the best way to manipulate dates/time is using other languages, like
vbscript or others.
Reply With Quote
  #5  
Old 08-27-2008, 02:19 PM
Default Re: %Date% returns different values....


"TimParker" schrieb im Newsbeitrag
news:e65305b3-4286-4af2-b486-c0b7feae4dd9@f63g2000hsf.googlegroups.com...

[...]

> I set up the script shown here:
>
> echo %COMPUTERNAME%, %USERNAME%, %date%, %TIME%, Login >> \
> \mopssrv01\MISData\MOPS-LOGONS.csv
>
>

[...]
>
> WKSTN0027 USER1 Mon 08/25/2008 9:04:02.45 Login
> WKSTN0014 USER2 08/25/2008 9:05:19.57 Login
> WKSTN0033 USER3 08/25/2008 9:05:21.96 Login
> WKSTN0021 USER4 Mon 08/25/2008 9:07:03.16 LogOut
>



In that case i have had an idea.
How about echo %date:~-10% instead the simple %date% for Your special
problem?
That will output the last 10 chars of the %date%.
The Day will be cut off.

Greetings
Carsten


Reply With Quote
  #6  
Old 08-27-2008, 08:34 PM
Default Re: %Date% returns different values....


"Carsten Beckermann" wrote in message
news:g945sh$ivm$00$1@news.t-online.com...
>
> "TimParker" schrieb im Newsbeitrag
> news:e65305b3-4286-4af2-b486-c0b7feae4dd9@f63g2000hsf.googlegroups.com...
>
> [...]
>
>> I set up the script shown here:
>>
>> echo %COMPUTERNAME%, %USERNAME%, %date%, %TIME%, Login >> \
>> \mopssrv01\MISData\MOPS-LOGONS.csv
>>
>>

> [...]
>>
>> WKSTN0027 USER1 Mon 08/25/2008 9:04:02.45 Login
>> WKSTN0014 USER2 08/25/2008 9:05:19.57 Login
>> WKSTN0033 USER3 08/25/2008 9:05:21.96 Login
>> WKSTN0021 USER4 Mon 08/25/2008 9:07:03.16 LogOut
>>

>
>
> In that case i have had an idea.
> How about echo %date:~-10% instead the simple %date% for Your special
> problem?
> That will output the last 10 chars of the %date%.
> The Day will be cut off.
>
> Greetings
> Carsten
>


Suppose another user has selected a two-digit-year date format?

Regardless, you may get users who prefer dd/mm/yy formats - which can get
really confusing at times. I once worked at a company where their mainframe
system used dd/mm/yy format but their microcomputer network was locked to
mm/dd/yy. The confusion caused by people mis-reading dates or failing to
convert the appropriate number of times cost millions - all for the sake of
two minutes' work which the people who had the microcomputer contract
refused to do.


Reply With Quote
  #7  
Old 08-27-2008, 10:26 PM
Default Re: %Date% returns different values....

billious wrote:
> "Carsten Beckermann" wrote in message
> news:g945sh$ivm$00$1@news.t-online.com...
> >
> > "TimParker" schrieb im Newsbeitrag
> >

news:e65305b3-4286-4af2-b486-c0b7feae4dd9@f63g2000hsf.googlegroups.com...
> >
> > [...]
> >
> >> I set up the script shown here:
> >>
> >> echo %COMPUTERNAME%, %USERNAME%, %date%, %TIME%, Login >> \
> >> \mopssrv01\MISData\MOPS-LOGONS.csv
> >>
> >>

> > [...]
> >>
> >> WKSTN0027 USER1 Mon 08/25/2008 9:04:02.45 Login
> >> WKSTN0014 USER2 08/25/2008 9:05:19.57 Login
> >> WKSTN0033 USER3 08/25/2008 9:05:21.96 Login
> >> WKSTN0021 USER4 Mon 08/25/2008 9:07:03.16 LogOut
> >>

> >
> >
> > In that case i have had an idea.
> > How about echo %date:~-10% instead the simple %date% for Your special
> > problem?
> > That will output the last 10 chars of the %date%.
> > The Day will be cut off.
> >
> > Greetings
> > Carsten
> >

>
> Suppose another user has selected a two-digit-year date format?


The following would be useful for that situation.
http://tinyurl.com/5z245c

>
> Regardless, you may get users who prefer dd/mm/yy formats - which can get
> really confusing at times. I once worked at a company where their

mainframe
> system used dd/mm/yy format but their microcomputer network was locked to
> mm/dd/yy. The confusion caused by people mis-reading dates or failing to
> convert the appropriate number of times cost millions - all for the sake

of
> two minutes' work which the people who had the microcomputer contract
> refused to do.


Your past employer should have told them who was working for who and put a
stop payment on the contract until the issue was resolved to their
satisfaction. OTOH, hind sight is 20/20.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Reply With Quote
  #8  
Old 08-28-2008, 02:25 AM
Default Re: %Date% returns different values....


> WKSTN0033 USER3 08/25/2008 9:05:21.96 Login
> WKSTN0021 USER4 Mon 08/25/2008 9:07:03.16 LogOu


The second string is win2K date format. Set new date var to solve
problem.

For example:
set udate=%date:~-10%

And use %udate%.
Reply With Quote
  #9  
Old 08-28-2008, 10:05 AM
Default Re: %Date% returns different values....


"Todd Vargo" wrote in message
news:H1otk.20547$89.14472@nlpi069.nbdc.sbc.com...
> billious wrote:
>> "Carsten Beckermann" wrote in message
>> news:g945sh$ivm$00$1@news.t-online.com...
>> >
>> > "TimParker" schrieb im Newsbeitrag
>> >

> news:e65305b3-4286-4af2-b486-c0b7feae4dd9@f63g2000hsf.googlegroups.com...
>> >
>> > [...]
>> >
>> >> I set up the script shown here:
>> >>
>> >> echo %COMPUTERNAME%, %USERNAME%, %date%, %TIME%, Login >> \
>> >> \mopssrv01\MISData\MOPS-LOGONS.csv
>> >>
>> >>
>> > [...]
>> >>
>> >> WKSTN0027 USER1 Mon 08/25/2008 9:04:02.45 Login
>> >> WKSTN0014 USER2 08/25/2008 9:05:19.57 Login
>> >> WKSTN0033 USER3 08/25/2008 9:05:21.96 Login
>> >> WKSTN0021 USER4 Mon 08/25/2008 9:07:03.16 LogOut
>> >>
>> >
>> >
>> > In that case i have had an idea.
>> > How about echo %date:~-10% instead the simple %date% for Your special
>> > problem?
>> > That will output the last 10 chars of the %date%.
>> > The Day will be cut off.
>> >
>> > Greetings
>> > Carsten
>> >

>>
>> Suppose another user has selected a two-digit-year date format?

>
> The following would be useful for that situation.
> http://tinyurl.com/5z245c
>
>>
>> Regardless, you may get users who prefer dd/mm/yy formats - which can get
>> really confusing at times. I once worked at a company where their

> mainframe
>> system used dd/mm/yy format but their microcomputer network was locked to
>> mm/dd/yy. The confusion caused by people mis-reading dates or failing to
>> convert the appropriate number of times cost millions - all for the sake

> of
>> two minutes' work which the people who had the microcomputer contract
>> refused to do.

>
> Your past employer should have told them who was working for who and put a
> stop payment on the contract until the issue was resolved to their
> satisfaction. OTOH, hind sight is 20/20.
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)
>


Touching innocence!

You are presuming that the decisions are made in the interests of the
business concerned, and appear not to have considered that the decision may
have been made for other reasons - like for instance the personal bank
balances of those actually making the decisions, for instance...


Reply With Quote
Reply

Thread Tools


All times are GMT -5. The time now is 06:55 PM.

In an effort to better serve ads to our visitors, cookies are used on Fixunix.com. For more information, check out our Privacy Policy.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Ad Management by RedTyger