+ Reply to Thread
Results 1 to 5 of 5

Formatting date

  1. #1
    Registered User
    Join Date
    11-13-2019
    Location
    Guelph, Ontario
    MS-Off Ver
    Many
    Posts
    9

    Formatting date

    Hello,

    Not sure how many of you work with ?printing? reports to .csv and then opening the .csv files in Excel.

    This is the situation.

    We run WIP report for a period to csv, then we run a macro which deletes whatever columns are not needed, creates formulas to correct dates imported as text or as date, format number, insert subtotals, etc., leaving a clean report.
    We do that on many reports.

    Since there are thousands of lines, I never noticed that Excel incorrectly presents the date. Duh!

    In the attached picture entries in columns for month, day and year are separated from the date dumped to csv using the Text to Columns function. Then the DATE formula uses those to create a date. Expected date, as in the picture is 2018 December 31.
    It turns out that Excel produces number 44024 which is in fact Jul 12th 2020.

    Did anyone encounter such behaviour and found a solution?

    WrongDate.JPG

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Formatting date

    My first impression is that you have confused the month and day columns.

    As currently written, you are asking for the date of the 2018th year + the 31st month + the 12th day. Of course, 31 months after Jan 2018 is July 2020, then the 12th day of that month, so 12 July 2020 is the correct day for 2018th year + 31st month + 12th day.

    If you intended for this to be 31 Dec 2018, it appears that you need to switch your C and D references. =DATE(E194210,C194210,D194210) [and, I suspect, up and down through the rest of the column].

    Have I understood your picture correctly? Are you able to switch those references in your formula? Is there some confusion in your text file so that month and day are sometimes switched?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Formatting date

    The screenshot you are showing indicates you are using 31 for the Month and 12 for the day. They are backwards in your formula.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    11-13-2019
    Location
    Guelph, Ontario
    MS-Off Ver
    Many
    Posts
    9

    Re: Formatting date

    Hello MrShorty.

    Yes, the formula is definitely wrong in this picture.
    But it is not incorrect as it starts.

    Please take a look at the two attached screenshots.WrongDate2.JPGWrongDate3.JPG

    The .csv file changes the format. At the top when macro enters formula it is correct. Then copied down creates a wrong date.
    Thank you for noticing. I wasn't even thinking about it.

    Will change the formula to accommodate the length of entry in the original cell and choose the correct Y/M/D selection.

    Thank you.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Formatting date

    As long as you can reliably infer the correct MYD/DMY/YMD/?? for each date, you should be able to piece together a formula. If you have any influence with the people generating the text file, if you can convince them to choose a date format and send the file with ALL of the dates in one format, it will be easier for you in the long run.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Conditional Formatting for Gant Chart based on : Start Date / End Date / Status
    By Stancur in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-23-2018, 04:13 AM
  2. Formatting Cells with Date or Text Values in a Conditional Formatting Formula
    By Phil Hageman in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-15-2014, 09:36 AM
  3. Replies: 3
    Last Post: 11-23-2013, 06:21 AM
  4. Replies: 2
    Last Post: 09-19-2013, 10:34 AM
  5. Replies: 5
    Last Post: 08-22-2012, 05:06 PM
  6. Replies: 3
    Last Post: 08-18-2010, 12:58 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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1