Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Formatting a date
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 33 of 33 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ritchie Lawrence  
View profile  
 More options Mar 19 2002, 9:37 am
Newsgroups: alt.msdos.batch.nt
From: "Ritchie Lawrence" <rlawre...@commanddoline.co.uk>
Date: Tue, 19 Mar 2002 14:37:02 -0000
Local: Tues, Mar 19 2002 9:37 am
Subject: Re: Formatting a date
Hi All,
After further deliberation, I now propose the following, for
retrieving the date on NT/2K/XP, independant of regional
settings. Anyone care to test it?

========================== getdate.cmd ==========================
@echo off&setlocal

set t=2&if "%date%z" LSS "A" set t=1
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo.^|date') do (
  for /f "tokens=%t%-4 delims=.-/ " %%d in ('date/t') do (
    set %%a=%%d&set %%b=%%e&set %%c=%%f))

echo Year=[%yy%] Month=[%mm%] Date=[%dd%]
=================================================================

If I can find a list of the various regional outputs, I think it
should be possible to get it back to a one-liner.

--
Ritchie
Undo my address for email.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Formatting a date under NT/2k/XP" by Simon Sheppard
Simon Sheppard  
View profile  
 More options Mar 19 2002, 1:58 pm
Newsgroups: alt.msdos.batch.nt, microsoft.public.win2000.cmdprompt.admin
From: si...@spam.invalid (Simon Sheppard)
Date: Sun, 17 Mar 2002 18:57:14 GMT
Local: Sun, Mar 17 2002 1:57 pm
Subject: Re: Formatting a date under NT/2k/XP
crossposted to microsoft.public.win2000.cmdprompt.admin

On Tue, 19 Mar 2002 14:37:02 -0000, "Ritchie Lawrence"

Interesting - here's something similar I tested today with a variety
of dates and regional settings under NT/2k/XP

   @echo off&setlocal
   for /f "tokens=1-4 delims=/-. " %%G in ('date /t') DO call
:s_fixdate %%G %%H %%I %%J
   goto :s_print_the_date

   :s_fixdate
   if "%1:~0,1%" GTR "9" shift
   for /f "skip=1 tokens=2-4 delims=(-)" %%G in ('echo.^|date') do (
       set %%G=%1&set %%H=%2&set %%I=%3)
   goto :eof

   :s_print_the_date
   echo Month: [%mm%]
   echo Day:   [%dd%]
   echo Year:  [%yy%]

-
Simon Sheppard
Web: http://www.ss64.com
email: Simon@ "
-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Formatting a date" by Simon Sheppard
Simon Sheppard  
View profile  
 More options Mar 19 2002, 2:23 pm
Newsgroups: alt.msdos.batch.nt
From: si...@spam.invalid (Simon Sheppard)
Date: Tue, 19 Mar 2002 19:22:47 GMT
Local: Tues, Mar 19 2002 2:22 pm
Subject: Re: Formatting a date
On Tue, 19 Mar 2002 04:02:07 GMT, Garry Deane

<garrydeane_at_yahoo.com.au> wrote:
>NOTES
>1) The "NET TIME \\machinename" command in Win XP ALWAYS gives date &
>time in a variant of the US date and time format, e.g. 5/23/2000 2:07
>PM, regardless of the Regional Options.

>John Gray  16-23OCT2001, 11-13FEB2002

This may be an easier method - though NET TIME requires the SERVER
service to be running (on %computername% ) the script below only
returns a 2 digit year, and it removes some leading zeros

   @echo off&setlocal

   FOR /f "tokens=6-9 delims=/ " %%G IN ('NET TIME \\%computername%')
DO (
         SET v_mm=%%G
         SET v_dd=%%H
         SET v_yy=%%I
         SET v_time=%%J)

   ECHO Today is Year: [%v_yy%] Month: [%v_mm%] Day: [%v_dd%]
   Echo The time is [%v_time%]

-
Simon Sheppard
Web: http://www.ss64.com
email: Simon@ "
-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Sheppard  
View profile  
 More options Mar 19 2002, 2:27 pm
Newsgroups: alt.msdos.batch.nt
From: si...@spam.invalid (Simon Sheppard)
Date: Tue, 19 Mar 2002 19:25:58 GMT
Local: Tues, Mar 19 2002 2:25 pm
Subject: Re: Formatting a date

nice bit of code - Thanks

-
Simon Sheppard
Web: http://www.ss64.com
email: Simon@ "
-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Formatting a date under NT/2k/XP" by Alex K. Angelopoulos
Alex K. Angelopoulos  
View profile  
 More options Mar 19 2002, 2:53 pm
Newsgroups: alt.msdos.batch.nt, microsoft.public.win2000.cmdprompt.admin
From: "Alex K. Angelopoulos" <watercooler...@netscape.net>
Date: Tue, 19 Mar 2002 14:53:15 -0500
Local: Tues, Mar 19 2002 2:53 pm
Subject: Re: Formatting a date under NT/2k/XP
Works fine on XP Pro, of course:

Year=[2002] Month=[03] Date=[19]

"Simon Sheppard" <si...@spam.invalid> wrote in message news:3c94e4d5.565783@news.demon.co.uk...

: crossposted to microsoft.public.win2000.cmdprompt.admin
:
: On Tue, 19 Mar 2002 14:37:02 -0000, "Ritchie Lawrence"
: <rlawre...@commanddoline.co.uk> wrote:

:
: >Hi All,
: >After further deliberation, I now propose the following, for
: >retrieving the date on NT/2K/XP, independant of regional
: >settings. Anyone care to test it?
: >
: >========================== getdate.cmd ==========================
: >@echo off&setlocal
: >
: >set t=2&if "%date%z" LSS "A" set t=1
: >for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo.^|date') do (
: >  for /f "tokens=%t%-4 delims=.-/ " %%d in ('date/t') do (
: >    set %%a=%%d&set %%b=%%e&set %%c=%%f))
: >
: >echo Year=[%yy%] Month=[%mm%] Date=[%dd%]
: >=================================================================
: >
: >If I can find a list of the various regional outputs, I think it
: >should be possible to get it back to a one-liner.
: >
: >--
: >Ritchie
:
: Interesting - here's something similar I tested today with a variety
: of dates and regional settings under NT/2k/XP
:
:    @echo off&setlocal
:    for /f "tokens=1-4 delims=/-. " %%G in ('date /t') DO call
: :s_fixdate %%G %%H %%I %%J
:    goto :s_print_the_date
:    
:    :s_fixdate
:    if "%1:~0,1%" GTR "9" shift
:    for /f "skip=1 tokens=2-4 delims=(-)" %%G in ('echo.^|date') do (
:        set %%G=%1&set %%H=%2&set %%I=%3)
:    goto :eof
:
:    :s_print_the_date
:    echo Month: [%mm%]
:    echo Day:   [%dd%]
:    echo Year:  [%yy%]
:
: -
: Simon Sheppard
: Web: http://www.ss64.com
: email: Simon@ "
: -

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Formatting a date" by Garry Deane
Garry Deane  
View profile  
 More options Mar 19 2002, 7:06 pm
Newsgroups: alt.msdos.batch.nt
From: Garry Deane <garrydeane_at_yahoo.com.au>
Date: Wed, 20 Mar 2002 00:01:51 GMT
Local: Tues, Mar 19 2002 7:01 pm
Subject: Re: Formatting a date
On Tue, 19 Mar 2002 14:37:02 -0000, "Ritchie Lawrence"

This won't work for NT, only W2k & XP automatically set %date%. For
NT, you need to do a prior FOR .. ('date/t')... to do this.

>If I can find a list of the various regional outputs, I think it
>should be possible to get it back to a one-liner.

I'll send a copy.

Garry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ritchie Lawrence  
View profile  
 More options Mar 20 2002, 3:37 am
Newsgroups: alt.msdos.batch.nt
From: "Ritchie Lawrence" <rlawre...@commanddoline.co.uk>
Date: Thu, 21 Mar 2002 08:36:09 -0000
Local: Thurs, Mar 21 2002 3:36 am
Subject: Re: Formatting a date

Hi Garry, you _DIDN'T_ test it then ;)

The other way I was thinking of was the same as that above, but scrap
the first line, and add to the second delims all the characters that
may be used for the DOW. Decided against because I've not been able to
find what abbreviations are used for all DOWs in all regions.

I could just add the whole alphabet, but as the delims is case sensitive,
that would 52 characters and even some regions don't used letters from
the 'standard', so I'll stick with the script above.

--
Ritchie
Undo my address for email.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Garry Deane  
View profile  
 More options Mar 20 2002, 4:32 am
Newsgroups: alt.msdos.batch.nt
From: Garry Deane <garrydeane_at_yahoo.com.au>
Date: Wed, 20 Mar 2002 09:30:11 GMT
Local: Wed, Mar 20 2002 4:30 am
Subject: Re: Formatting a date
On Thu, 21 Mar 2002 08:36:09 -0000, "Ritchie Lawrence"

Oops - yeah you're right. Quite neat.

>The other way I was thinking of was the same as that above, but scrap
>the first line, and add to the second delims all the characters that
>may be used for the DOW. Decided against because I've not been able to
>find what abbreviations are used for all DOWs in all regions.

>I could just add the whole alphabet, but as the delims is case sensitive,
>that would 52 characters and even some regions don't used letters from
>the 'standard', so I'll stick with the script above.

I agree

Garry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »