+ Reply to Thread
Results 1 to 13 of 13

Dates are incorrect due to inconsistent formats

  1. #1
    Registered User
    Join Date
    02-14-2014
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    6

    Dates are incorrect due to inconsistent formats

    Hi there,

    I have a large number of rows (60,000+) that holds timestamped data at 15 minute increments that I have imported from CSV files. My problem is that Excel seems to have gotten some of the dates wrong when importing it and I need to retrospectively correct it. It seems to be happening for the first 12 days of each month. For example, the date will go from 31/08/12 11:45:00 PM (correct) to 09/01/12 12:00:00 AM (incorrect). Once that gets to 09/12/12 11:45:00 PM (incorrect) the next row is 13/09/12:00:00 AM (correct). This is NOT a formatting issue - all cells are formatted as DD/MM/YYYY HH:MM:SS AM/PM and text to columns does not fix it.

    I thought I could just us an IF statement to determine when the difference between two cells was more than 15 minutes but the problem is that the range is not contiguous i.e. there are periods of no measurements that have been removed so jumps in time do occur. I need a non-destructive way to fix this across many files.

    Thanks.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Dates are incorrect due to inconsistent formats

    Hi,

    I'd be looking for spaces or extra spaces in your data. Try to Trim the incorrect dates and see what happens. Also, sometimes there are character 160 hiding in data that comes from other places. It looks like a space but isn't. Look for Char(160) in your data also.

    Hope that helps. You might also post a short sample of your data with some good and bad dates.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Dates are incorrect due to inconsistent formats

    Hi and welcome to the forum

    This sounds like a US/AUZ date thing. excel probably things that the dates up to the 12th day, are actually up to the 12 th month. You can put a left/mid/right formula to pull them back into the correct format
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    02-14-2014
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Dates are incorrect due to inconsistent formats

    Hey MarvinP,

    Thanks for the quick response. I just tried to trim and checked for char(160) but with no luck. I suspect that when importing the DD format Excel chose to ignore the leading zero on some dates and then thought it was in MM/DD format as a result.

    I have attached a small excerpt from one of the files for reference. Date error example.xlsx

    Thanks

  5. #5
    Registered User
    Join Date
    02-14-2014
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Dates are incorrect due to inconsistent formats

    Thanks. I spend a lot of time perusing but it's my first time posting.

    Thanks for the suggestion. But wouldn't that only work if all of them were using the incorrect format? The problem cells are interspersed throughout the sheets. I have so many rows that going through them manually to determine which are incorrect would be a massive undertaking.

  6. #6
    Registered User
    Join Date
    02-14-2014
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Dates are incorrect due to inconsistent formats

    I just took a closer look at the example file I attached..the problem appears to worse than first thought because the actual value is wrong there. I might have to manually rebuild it from scratch using the original CSV files to over come this problem. Sigh.

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Dates are incorrect due to inconsistent formats

    I was able to convert it to dates by using this formula

    =IFERROR(--TRIM(A1),TRIM(A1))
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Dates are incorrect due to inconsistent formats

    OK here is a bit of a long-winded way around what you are doing, using 2 helper columns. I used D and E.

    In D1, copied down...
    =TEXT(A1,"dd/mm/yyyy")
    Then in E1, copied down...
    =DATE(MID(D1,7,IF(ISERROR(FIND(" ",A1,1)),4,2)),MID(D1,4,2),LEFT(D1,2))

    Once you have them all converted, you can copy/paste values over your "dates" and then delete those 2 helpers

  9. #9
    Registered User
    Join Date
    02-14-2014
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Dates are incorrect due to inconsistent formats

    Quote Originally Posted by AlKey View Post
    I was able to convert it to dates by using this formula

    =IFERROR(--TRIM(A1),TRIM(A1))
    Thanks for your help. I tried this and it does convert the cells to dates, but the resulting numbers are still incorrect for the rows where the dd/mm have been swapped for mm/dd during the import process.

  10. #10
    Registered User
    Join Date
    02-14-2014
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Dates are incorrect due to inconsistent formats

    Quote Originally Posted by FDibbins View Post
    OK here is a bit of a long-winded way around what you are doing, using 2 helper columns. I used D and E.

    In D1, copied down...
    =TEXT(A1,"dd/mm/yyyy")
    Then in E1, copied down...
    =DATE(MID(D1,7,IF(ISERROR(FIND(" ",A1,1)),4,2)),MID(D1,4,2),LEFT(D1,2))

    Once you have them all converted, you can copy/paste values over your "dates" and then delete those 2 helpers
    I tried this also but to no avail. Thanks for the help guys but I think this is a problem which can't be fixed. I'll just need to rebuild all the files. Thanks for your help.

  11. #11
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Dates are incorrect due to inconsistent formats

    Lets give it another try

    =--IFERROR(TEXT(--TRIM(A1),"dd/mm/yyyy"),--MID(A1,4,2)&"/"&LEFT(A1,2)&TEXT(MID(A1,6,3),"yyyy"))

  12. #12
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Dates are incorrect due to inconsistent formats

    as people have said they are probably us/aus dates and once imported as dates 6/5/2014 will be seen as 6 may but should be 5 june
    dates as 6/30/214 will not be resolved and its too late to fix the 6/5/2015 as excel has already changed it to a date number
    one way is to import as text so the dates all keep their original format
    then use text to columns and use mdy to convert your dates so thay will be correct as per your date format
    if that doesnt work temporarily change your regional settings to us ,import the data then change settings back to aus
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  13. #13
    Registered User
    Join Date
    01-10-2017
    Location
    Peterborough, Canada
    MS-Off Ver
    2013
    Posts
    1

    Re: Dates are incorrect due to inconsistent formats

    Quote Originally Posted by AlKey View Post
    Lets give it another try

    =--IFERROR(TEXT(--TRIM(A1),"dd/mm/yyyy"),--MID(A1,4,2)&"/"&LEFT(A1,2)&TEXT(MID(A1,6,3),"yyyy"))
    Hi AlKey,

    I was having the same issue as TPar7322 and this formula works! Thanks!

    However my A1 column also includes hh:mm:ss data that I also want to move over from the "A1" column. HOw would I modify the formula to carry over the data? Thanks!

+ 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. Trouble with inconsistent date formats in Excel
    By chifoobear in forum Excel General
    Replies: 6
    Last Post: 07-21-2013, 11:50 AM
  2. Splitting Names with inconsistent formats
    By andersonca in forum Excel General
    Replies: 2
    Last Post: 06-24-2009, 01:44 PM
  3. date formats incorrect when VBA opens workbook
    By rinkon in forum Excel General
    Replies: 9
    Last Post: 05-06-2008, 11:36 PM
  4. Help! ISO formula for inconsistent monthly dates
    By Yeah in forum Excel General
    Replies: 12
    Last Post: 08-26-2006, 10:52 AM
  5. Incorrect Date Formats
    By Mark in forum Excel General
    Replies: 2
    Last Post: 03-24-2006, 01:25 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