Solved

Dos Command DATE /T doesn't display DAY

Posted on 2004-04-26
11
1,579 Views
Last Modified: 2011-09-20
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
Comment
Question by:simonprr
  • 5
  • 5
11 Comments
 
LVL 59

Expert Comment

by:LeeTutor
ID: 10923969
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
 
LVL 6

Accepted Solution

by:
mrdtn earned 250 total points
ID: 10924358
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
 
LVL 3

Author Comment

by:simonprr
ID: 10926859
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 3

Author Comment

by:simonprr
ID: 10927048
Ah I got it...

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

Worked nicely :)

Thanks for your help.
0
 
LVL 6

Expert Comment

by:mrdtn
ID: 10928905

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
 
LVL 6

Expert Comment

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

--

mrdtn
0
 
LVL 3

Author Comment

by:simonprr
ID: 10929923
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
 
LVL 6

Expert Comment

by:mrdtn
ID: 10930518
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
 
LVL 3

Author Comment

by:simonprr
ID: 10937233
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
 
LVL 6

Expert Comment

by:mrdtn
ID: 10941271
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
 
LVL 3

Author Comment

by:simonprr
ID: 10944118
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like 192.168.xxx.1, I've seen routers with default values of: 192.168.0.1, 192.168.1.1, 192.168.11.1, …
Can you find a fax from a vendor you saved a decade ago in seconds? Have you ever cursed your PC under your breath during an audit because you couldn’t find the requested statement or driver history?  If you answered no to the first question or yes …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question