+ Reply to Thread
Results 1 to 4 of 4

Date Format

  1. #1
    Registered User
    Join Date
    01-20-2006
    Posts
    68

    Date Format

    Dear all,

    Win local format is "dd/mm/yy"

    in VBA

    Cells(1, 1) = "08/02/2006"

    in Excel sheet display

    "02/08/06" in A1

    What happen?

  2. #2
    Norman Jones
    Guest

    Re: Date Format

    Hi Gabch,

    Try:

    Cells(1, 1).Value = DateValue("08/02/2006")


    ---
    Regards,
    Norman



    "gabch" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Dear all,
    >
    > Win local format is "dd/mm/yy"
    >
    > in VBA
    >
    > Cells(1, 1) = "08/02/2006"
    >
    > in Excel sheet display
    >
    > "02/08/06" in A1
    >
    > What happen?
    >
    >
    > --
    > gabch
    > ------------------------------------------------------------------------
    > gabch's Profile:
    > http://www.excelforum.com/member.php...o&userid=30662
    > View this thread: http://www.excelforum.com/showthread...hreadid=536337
    >




  3. #3
    Mat P:son
    Guest

    RE: Date Format

    The Windows Regional Settings dictates, among other things, how Excel should
    present dates.

    However, the VBA code is primarily using US format for dates. Hence,
    Cells(1, 1) = "08/02/2006" means 02-Aug-2006 (US mm/dd/yyy), and it then gets
    translated into "02/08/2006" (which means 02-Aug-2006 in your UK format)
    during the presentation stage, i.e., when Excel displays the date in cell A1.

    By the way, you can also use the following construct in the future:

    Cells(1, 1) = #2/8/2006#

    The #..# literal is explicitly of type Date (and, yes, it's in US format) so
    you know what you'll get. A string, however, can basically be anything you
    like...

    Cheers,
    /MP

    "gabch" wrote:

    >
    > Dear all,
    >
    > Win local format is "dd/mm/yy"
    >
    > in VBA
    >
    > Cells(1, 1) = "08/02/2006"
    >
    > in Excel sheet display
    >
    > "02/08/06" in A1
    >
    > What happen?
    >
    >
    > --
    > gabch
    > ------------------------------------------------------------------------
    > gabch's Profile: http://www.excelforum.com/member.php...o&userid=30662
    > View this thread: http://www.excelforum.com/showthread...hreadid=536337
    >
    >


  4. #4
    Registered User
    Join Date
    01-20-2006
    Posts
    68

    date format convert

    Hi,

    How can I convert UK date format(dd/mm/yy) at cell to US format (mm/dd/yy) through VBA

+ 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