+ Reply to Thread
Results 1 to 7 of 7

Default Date Format

  1. #1
    Forum Contributor
    Join Date
    01-10-2006
    Location
    Ahmedabad, India
    MS-Off Ver
    Office 2000
    Posts
    346

    Default Date Format

    In my Regional And Language setting the date format is dd/MM/yyyy and Excel does map the date entered in any cell to this format. eg if I start on a fresh excel sheet and enter 4/5/6 in any cell or I have a code line say [a1]=Cdate("4/5/6"), it displays as 04/05/2006 as expected. If I reformat the cell as dd-mmm-yyyy it correctly shows 04-May-2006 indicating excel has taken 4 as day, 5 as month and 6 as year.
    However if my code is [a1]= "4/5/6" then A1 dispalys 4/5/2006 and if I format the cell as dd-mmm-yyyy it shows 05-April-2006. It shows that it tries to map the string to M/d/yyyy format. Same is true with Cstr. If my date is 04-May-2006 , Cstr converts it to the string "4/5/2006". One more observation - if I want to use literal date and try to type in a code line say [a1]= # 4 May 2006 # it automatically changes to [a1]=#4/5/2006# as soon as I complete the line and hit the return.

    I have come to a conclusion that Excel has two different formats it tries to map the probable date strings to . One is the Regional setting and the other is M/d/yyyy which seems to be its own default setting. Am I right? If yes, then I want to know if I can have access to this default Excel preferred setting. And can if I change that also to dd/MM/yyyy?

    A V Veerkar
    Last edited by avveerkar; 06-13-2007 at 10:48 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Excel gets its default formatting from your operating system's time/date formatting. I use that feature to change the time seperator to something that doesn't need a Shift. It also works with date formatting.

  3. #3
    Forum Contributor
    Join Date
    01-10-2006
    Location
    Ahmedabad, India
    MS-Off Ver
    Office 2000
    Posts
    346
    Quote Originally Posted by mikerickson
    Excel gets its default formatting from your operating system's time/date formatting. I use that feature to change the time seperator to something that doesn't need a Shift. It also works with date formatting.
    I use XP. How do I access the time and date format. I only know how to set date and time but do not know how to access the display format.

    Thank you

    A V Veerkar

  4. #4
    Registered User
    Join Date
    11-28-2006
    Posts
    17

    Example

    Here's a small code to see date format work, please notice that the format function works for String data type.

    Please Login or Register  to view this content.
    Try and let me know.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I'm a Mac user. Someone here must be XP wise.

  6. #6
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    VBA only understands US date format ie MDY whereas Excel itself will use the System settings.

    Richard

  7. #7
    Forum Contributor
    Join Date
    01-10-2006
    Location
    Ahmedabad, India
    MS-Off Ver
    Office 2000
    Posts
    346
    Quote Originally Posted by RichardSchollar
    VBA only understands US date format ie MDY whereas Excel itself will use the System settings.

    Richard
    Richard,

    What you say makes sense. VBA understands only US format (M/d/yyyy) but Excel will follow the format set in system Regional and Language panel. And also I understand that there is no way we can change VBA default setting.

    A V Veerkar

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1