Results 1 to 4 of 4

Thread: How to display date with 0 in front

  1. #1
    Join Date
    Sep 2009
    Posts
    143

    How to display date with 0 in front

    I have a CSV file which I am trying to open with Excel 2007. It was generated by a PHP script. In a column, I have dates in the format ddmmyyyy without separation. These dates can be performed in many formats, text, standard or date, whatever. My only problem is when I have a date with a 0 in front (eg 02112009) The 0 is not displayed, or it should be mandatory.

    How do I get that 0 is displayed in the CSV file? FYI, when I open the file with notepad, the 0 is there.

  2. #2
    Join Date
    May 2008
    Posts
    271

    Re: How to display date with 0 in front

    It is quiet normal that you can see in NotePad but not in Excel simply because there are altogether different.

    If you pass the date 01102009, Excel will remove the 0 "not significant" to the left, and then interpret the data as the number 1102009.

    Possible solutions:
    - Change the extension TXT: On opening the file using Excel, you can specify the date format of the column and Excel will interpret correctly your data.

    - Open the file as it is and then treat it in Excel or VBA. For example, in Excel, you can have

    Code:
    =DATE(RIGHT (A1,4);IF(LEN(A1)=7;MID(A1,2,2);MID (A1,3,2));IF(LEN(A1)=7;LEFT(A1,1);LEFT(A1,2)))

  3. #3
    Join Date
    Sep 2009
    Posts
    143

    Re: How to display date with 0 in front

    None of your two solutions work at my place. Is there a solution to this problem?

  4. #4
    Join Date
    May 2008
    Posts
    271

    Re: How to display date with 0 in front

    Also check that the date column, once recovered in Excel is in a format of dd/mm/yy or dd/mm/yyyy.

    If it does not matter that the value of "rest" is in number format, you can pass in custom size: 0 #######

    The "0" of the early forces the display of a figure in 8th position (counting from the right).

Similar Threads

  1. Replies: 3
    Last Post: 29-07-2011, 08:33 AM
  2. Display System date & time to VB application
    By VijayW in forum Software Development
    Replies: 3
    Last Post: 16-02-2009, 07:53 PM
  3. How can I display system date & time on my webpage?
    By JangoRap in forum Software Development
    Replies: 3
    Last Post: 16-02-2009, 07:40 PM
  4. How to Display Date 30 Days From Today
    By Gayan in forum Software Development
    Replies: 1
    Last Post: 19-12-2008, 02:52 PM
  5. How to display password expiry date for all users
    By Antonio00 in forum Active Directory
    Replies: 2
    Last Post: 26-02-2008, 01:49 PM

Tags for this Thread

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
  •  
Page generated in 1,713,916,114.66771 seconds with 17 queries