Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1585
  • Last Modified:

Dos Command DATE /T doesn't display DAY

Hi,
Simple problem...

On my XP Pro (SP1) PC if I do date /t in the command prompt I get:

27/04/2004

On my 2000 Server (SP4) I get:

Tue 27/04/2004

I want to be able to get the DAY name on my XP PC... how do I do it? The regional settings are the same on my 2000 Server as my XP PC and set to United Kingdom.

Apparently, some people do get the day on XP when they do this command... I have no idea what is different on their PCs...should be exactly the same.

So any ideas?
What do you get? Please, also let me know OS details and what country you have your regional settings set to.

Thanks :)
0
simonprr
Asked:
simonprr
  • 5
  • 5
1 Solution
 
LeeTutorretiredCommented:
Well, I get the day of the week when I do that command.  I have WinXP Pro, and my Regional Options page has English (United States).
0
 
mrdtnCommented:
Here's a regional format independent solution.  Check out the link below and look at the post from 04/23/2004 10:40PM EDT.  Change the "pushed" date format to what you need -- in your case probably "ddd dd/MM/yyyy".

http://oldlook.experts-exchange.com:8080/Operating_Systems/MSDOS/Q_20956707.html

--

Hope this helps.  Let me know if you have ?????s
0
 
simonprrAuthor Commented:
Thanks mrdtn, however my firewall blocks all ports other than 80, so I can't view that PAQ... any other way to see it?

Not sure where I change the "pushed" date?!? Can you direct please.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
simonprrAuthor Commented:
Ah I got it...

Regional Options > Customise > Date tab > Short date format: ddd dd/MM/yyyy

Worked nicely :)

Thanks for your help.
0
 
mrdtnCommented:

http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20956707.html

If you want to work with a particular date format from within a batch script without permanently changing it, this will do so.  You basically "call :pushdfmt" at the beginning and "call :popdfmt" at the end.  You would shange the line

         >> _%tempfile% echo "!reg_string!"="yyyyMMdd"
to
         >> _%tempfile% echo "!reg_string!"="ddd dd/MM/yyyy"

It seems you weren't necessarily asking for that, in case you want to be able to change formats arount from within a script, check the link out.

--

mrdtn
0
 
mrdtnCommented:
Sorry . . I should have just said Control panel > Regional and Language Options > Customise > Date Tab > Short Date Format . . .

--

mrdtn
0
 
simonprrAuthor Commented:
Don't understand what you mean by the that date stuff in a batch file... can you explain better please?

I have discovered a problem with changing the short date format though. Now in Outlook, all my messages, calender entries etc are appearing like:

Tue 27 04 2004

Without the slashes! If I turn them on in the regional settings, then the date /t command does display correctly (which does display the slashes)

Any ideas?

0
 
mrdtnCommented:
You need to change the long date format for Outlook to display correctly, http://support.microsoft.com/?kbid=254592.

I'm not sure why Outlook gets confused when the short date format only is changed.  I saw exactly what you described, and could only get Oulook to display ddd-dd/mm/yyyy or ddd/dd/mm/yyyy in several tests.  It's strange that modifying the short date format has any effect at all if Outlook is supposed to inherit that info from the long format.

Anyway, I tried it and it works.

--

mrdtn

--

P.S.  If you're not writing batch scripts, don't worry about it.  Otherwise, I recommend reading the post I referenced before (04/23/2004 10:40PM EDT) from the link provided, as it demonstrates the use of the pushdfmt and popdfmt.

0
 
simonprrAuthor Commented:
So what should I get the long date format to? This is werid cause it's not consistent.

Short date format: ddd dd/MM/yyyy
Long date format: dd MMMM yyyy

It is using the short date format in most cases like in the command prompt and windows explorer, but Outlook is displaying it without the slashes.
Doesn't make sense to me.

Actually, I am writing a batch file. I will read that other question and get back to you if I have any questions about it.

See my other question: http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20962395.html
0
 
mrdtnCommented:
Hi simonprr,

I got outlook to display the date formatted like Tue 27/04/2004 by actually typing in "ddd dd/MM/yyyy" (without the quotes) into the long date format field.  The format is not one of the options you will see when you click on the down arrow, but you can type in your own.  I'm not sure about the inconsistencies, but sometimes I accept what works.  Hopefully some info exists somewhere which can explain the inconsistencies.

I have seen your other question, and actually started to write up a solution, but I got sidetracked with other necessary tasks.  In another question (the link I posted earlier), I had written up a solution which worked on my machine where the date format (short) was MM/DD/YYYY, and  my code relied on that fact in order to parse out the month day and year properly.  This was important because I was doing math on these items.  Problem was that the author of that question lives in England where it is customary to use a DD/MM/YYYY format.  Needless to say, my initial code produced strange results since I was interpreting the month and day in reverse.  Further realizing that someone may customize their system to use a date format which is completely different (for example using hyphens instead of slashes to seperate the date components), I came up with a method which changes the date format to one of my choosing -- but only within the scope of the batch file which is running.  The batch file issues a "call :pushdfmt" to change the date format to the "working format" at the beginning and when it has done its job, it issues a "call :popdfmt" to return the date format to what it was originally -- thus effecting no permanent change to the system configuration.  This method (which I intend to use for all future batch code I write which is date related) allows me to deal with date variables which will always be consistent -- no matter what the regional settings have been configured to.  The only potential drawback to my method is it involves registry functions -- which may be limited to non-administrative accounts.  As you can see in my application of these functions in the link I posted, the date parsing becomes very simple, since I have "forced" the format to yyyymmdd.

--

mrdtn
0
 
simonprrAuthor Commented:
I will try this and let you know... so when is the long date format (as it is at the minute) used??

Long date format: dd MMMM yyyy

I don't see it anywhere like that?!


Yes, thats very interesting... however actually this code (below) that SteveGTR gave me, checks the output date and sets the variables as required in the right order to the right values... not sure how exactly, but it works:

====================================================
@echo off
setlocal

set yyyy=

set $tok=1-3
for /f "tokens=1 delims=.:/-, " %%u in ('date /t') do set $d1=%%u
if "%$d1:~0,1%" GTR "9" set $tok=2-4
for /f "tokens=%$tok% delims=.:/-, " %%u in ('date /t') do (
 for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do (
    set %%x=%%u
    set %%y=%%v
    set %%z=%%w
    set $d1=
    set $tok=))

if "%yyyy%"=="" set yyyy=%yy%
if /I %yyyy% LSS 100 set /A yyyy=2000 + 1%yyyy% - 100

for /f "tokens=1" %%a in ('date /t') do set day=%%a
====================================================

Maybe this can be an alternative.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now