+ Reply to Thread
Results 1 to 20 of 20

several date formats used in the same column. Unable to unify them.

  1. #1
    Registered User
    Join Date
    12-21-2020
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    8

    Post several date formats used in the same column. Unable to unify them.

    Hey experts!

    I am currently maintaining a data base of which several columns represent a date and time. The report currently has 200000+ lines involved. The data is pulled from a report in CSV format.

    It turns out that the source report creator changed their date format somewhere in the past. The changed format is visible in the formula bars and shows the follow distinct format differences:

    Format 1: 'M/D/YYYY H:MM' (Example: 4/19/2020 21:18)
    Format 2: 'M/D/YYYY H:MM:SS' (Example: 04/06/2020 06:49:00)

    The result is that the end product (report) will not correctly reflect all the values within the source data due to the date format difference.
    As such I am looking for a way to unify the formats, which i am currently having some issues with. i have tried the following to unify the data set:

    1.) Changing the date formats for the entire columns via CTRL+1 and selecting a date format.
    2.) Trying to change the data from text to date by using text to columns.

    The results of this is that 'Format 1' will stay in the same format, regardless of what i do to change the date formats, while 'Format 2' will change without issue.

    I have attached a sample excel file. The apparently unmovable data can be found in the first 4 lines. Would any of you be willing to guide me to what i am missing?

    Regards,

    Neogenic - an Excel padawan
    Attached Files Attached Files
    Last edited by Neogenic; 12-22-2020 at 05:35 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: several date formats used in the same column. Unable to unify them.

    Welcome to the forum.

    Are you using Office 365? If so, please update your forum profile.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    12-21-2020
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    8

    Re: several date formats used in the same column. Unable to unify them.

    Hi and thanks! Yes i am using 365. I will amend my profile now.

  4. #4
    Registered User
    Join Date
    08-09-2016
    Location
    Boston
    MS-Off Ver
    Office 365
    Posts
    37

    Re: several date formats used in the same column. Unable to unify them.

    For whatever reason the top half of your dates are not saved in excel as date codes. They are text. It needs the background date code in order to change the formatting.

    Insert a helper column next to the affected columns. (we can delete the column after.)

    Lets say column A is a date. In column B have the following formula refer to column A.

    =DATEVALUE(TEXT(A2,"MM/DD/YYY"))+TIMEVALUE(TEXT(A2,"HH:MM:SS"))

    You could then copy and paste the values over the original column and format in whichever format you'd like.

    Attached in the resolved example of your spreadsheet.
    Attached Files Attached Files
    Last edited by L.J.; 12-21-2020 at 11:27 AM.

  5. #5
    Registered User
    Join Date
    08-09-2016
    Location
    Boston
    MS-Off Ver
    Office 365
    Posts
    37

    Re: several date formats used in the same column. Unable to unify them.

    on further thought my worry is that when you update the report query that the older codes would just re-overwrite the work we just did. There may be a query option (can't help you there) that'll fix that. You may need to keep the helper columns for those dates and just use those converted columns as your date columns for your end report.

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,716

    Re: several date formats used in the same column. Unable to unify them.

    There is another problem, in that if the dates in the .csv file are generally of the format month/day/year (i.e. USA format) and your system is set for UK format, then a "date" like 04/06/2020 (which is meant to be 6th April 2020) would be taken by your version of Excel as meaning 4th June 2020.

    Instead of opening the .csv files by double clicking them (or using File | Open), you should use the Text Import Wizard, and this allows you to specify on the third panel which format to use for import (i.e. MDY rather than DMY).

    Alternatively, you could use a formula to convert those dates to what they should be, and then fix the values, but with 200,000+ rows this would take some time to calculate.

    Hope this helps.

    Pete

  7. #7
    Registered User
    Join Date
    12-21-2020
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    8

    Re: several date formats used in the same column. Unable to unify them.

    Quote Originally Posted by Pete_UK View Post
    There is another problem, in that if the dates in the .csv file are generally of the format month/day/year (i.e. USA format) and your system is set for UK format, then a "date" like 04/06/2020 (which is meant to be 6th April 2020) would be taken by your version of Excel as meaning 4th June 2020.

    Instead of opening the .csv files by double clicking them (or using File | Open), you should use the Text Import Wizard, and this allows you to specify on the third panel which format to use for import (i.e. MDY rather than DMY).

    Alternatively, you could use a formula to convert those dates to what they should be, and then fix the values, but with 200,000+ rows this would take some time to calculate.

    Hope this helps.

    Pete

    Hey experts,

    Thank you both for your good suggestions.

    So the whole sheet has lots of columns, 12 of which are date columns. The rows number over 200K+. What is a blessing is that, although the data is processed in CSV format, the monthly addition is limited in number of rows.
    The current issue is only to unify the dates. With an amount of around 1,5 million cells though, i would rather not do so manually.

    I have re-added the Legacy Wizard > Text Files version of the import wizard in order to try and force all dates in a unified MDY format. However, this version of the wizard seems to function in the same manner as the 'text to columns' and is showing the same results; part of the formatted data refuses to be transformed from text to a date format.

    Has anyone ever experienced this before? Do we know why part of the data refuses to be reformatted?

    Neogenic - an Excel padawan

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

    Re: several date formats used in the same column. Unable to unify them.

    Do we know why part of the data refuses to be reformatted?
    As has already been noted, the reason is that part of the data is still text (and, I expect, the other part has been incorrectly imported). The solution is to convince Excel to import the data correctly. Without knowing exactly what you did with the text import wizard, it is difficult to say why your latest attempts have failed. One way or another the solution is to import the text file in a way that allows Excel to correctly read the text and convert the date text to real date/time serial numbers. Exactly what did you try in your latest attempts with the text import wizard? I would have expected:

    1) Text import wizard step 1 -- delimited.
    2) text import wizard step 2 -- choose the appropriate delimiter (comma??)
    3) text import wizard step 3 -- for the columns containing date/time text, choose the Date option and specify MDY in the dropdown.
    4) double check the text import to see if everything imported correctly.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  9. #9
    Registered User
    Join Date
    12-21-2020
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    8

    Post Re: several date formats used in the same column. Unable to unify them.

    Hi MrShorty,

    Please see attached a file which shows screenshots of the actions which i took, as well as a new example file of the results.

    Excel seems to persists in viewing some of the imported data, specifically the once which in seem to be marked with 2 digits after each slash,
    as text rather than date values.

    I am trying to find out why this is happening, because i am hoping to correct this en mass.

    Regards,

    Neogenic
    Last edited by AliGW; 12-22-2020 at 05:34 AM. Reason: PLEASE don't quote unnecessarily!

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: several date formats used in the same column. Unable to unify them.

    Try in D2:

    Please Login or Register  to view this content.
    Darg down and to column E

    it change day to month and vice versa.
    Quang PT

  11. #11
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: several date formats used in the same column. Unable to unify them.

    @neogenic
    Administrative Note:

    Please don't quote entire posts unnecessarily. They clutter threads and make them hard to read.
    Use the "Quick reply" instead
    Thanks

  12. #12
    Registered User
    Join Date
    12-21-2020
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    8

    Re: several date formats used in the same column. Unable to unify them.

    Quote Originally Posted by bebo021999 View Post
    Try in D2:

    Darg down and to column E

    it change day to month and vice versa.
    That did it! Thank you!

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: several date formats used in the same column. Unable to unify them.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  14. #14
    Registered User
    Join Date
    12-21-2020
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    8

    Re: several date formats used in the same column. Unable to unify them.

    Hi AliGW,

    Thanks for the tip. I have done both actions now.

    Thanks

    Neogenic

  15. #15
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,716

    Re: several date formats used in the same column. Unable to unify them.

    The reason you are getting text dates is because the number between the two slashes (which represents days in US format but which your system will interpret as months) is greater than 12 - Excel can't make sense of that, and so it returns it as text.

    In your example file you can change all the "dates" to the correct format by using this formula (e.g. in D2):

    =IF(ISNUMBER(A2),DATE(YEAR(A2),DAY(A2),MONTH(A2))+A2-INT(A2),DATE(MID(A2,FIND("/",A2,3)+1,4),LEFT(A2,FIND("/",A2)-1),MID(A2,FIND("/",A2)+1,2))+RIGHT(A2,LEN(A2)-FIND(" ",A2)))

    Basically, if the cell is a number (i.e. it has been interpreted as a date) then reverse the day and month, otherwise extract the appropriate values from the text and convert to a date. Apply a custom format of dd/mm/yyyy hh:mm:ss to the cell (and widen it to see them all), then copy down to D30. You can also copy across into column E to change the dates in column B. As I said before, this will take some time to calculate if you have 200,000+ rows (and 12 columns), but once you have done that you can fix the values and delete the original columns, and then save it as an .XLSX file so you won't have to do it again.

    Hope this helps.

    Pete

    EDIT: I suppose I should have refreshed the screen before posting !!
    Last edited by Pete_UK; 12-22-2020 at 06:04 AM.

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

    Re: several date formats used in the same column. Unable to unify them.

    I notice that bebo021999 and Pete_UK's solutions are focused on fixing the issue after import. If you are happy with that, then you can ignore this. Going through your screenshots, it appears that you are specifying DMY dates at the 3rd step of the import wizard. I have seen others who have mistakenly believed that this step is telling Excel what you want the dates to look like after import, but that is not what you are specifying here (you will use number formatting after import to specify what you want the dates to look like). At this step of the text import wizard, you are telling Excel what to look for in the text file. By specifying DMY at this step, Excel will take the first date, for example, and interpret is as 4th day of the 20th month of the year 2020, which, of course, makes no sense, so it leaves it as text.

    I expect that, if you will specify MDY dates at this step of the wizard, then Excel will be able to interpret these dates correctly at import (remember that you can use number formatting after the import to display them however you want) and you won't need formulas to fix the dates after import.

    If you're happy with the post import formulas to fix the import, then you can ignore this. If you are interested in fixing this at import rather than after import, you can try specifying MDY dates while importing.

  17. #17
    Registered User
    Join Date
    12-21-2020
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    8

    Post Re: several date formats used in the same column. Unable to unify them.

    -Can't post links yet-

    Hi MrShorty,

    Thanks for the valuable tip. I certainly fell into the same pit trap when it comes to using the import wizard. Unfortunately the file is simply too large and Excel runs out of resources when trying to import the data. Unfortunately that means that the only way to reliable unify the data is through a formula. I do appreciate the tip though.
    Now to convert this sheet correctly into Tableau, which is another world of issue on it's own.

    Neogenic
    Last edited by Neogenic; 12-24-2020 at 07:02 AM. Reason: Spelling

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: several date formats used in the same column. Unable to unify them.

    Why are you trying to post a link???

    You can't until you have at least 10 posts.

  19. #19
    Registered User
    Join Date
    12-21-2020
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    8

    Re: several date formats used in the same column. Unable to unify them.

    Please note that i mean link as is using "at" to address someone. The resulting "error message" gives me the same reasoning when i try to do that. See attached screenshot if you are interested.
    Attached Images Attached Images

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: several date formats used in the same column. Unable to unify them.

    You will be able to use it once you have made 10 posts (but it won't produce a live link, as we don't have that facility).

+ 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. Replies: 4
    Last Post: 01-23-2020, 04:45 PM
  2. [SOLVED] Unable to Unify Font
    By Ian.Lance in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 04-19-2019, 12:01 PM
  3. Unify Dates - Mixed text and Date
    By makuchson in forum Excel General
    Replies: 4
    Last Post: 03-08-2019, 02:55 PM
  4. [SOLVED] Different Date Formats In Same Column
    By Samiramriti in forum Excel General
    Replies: 9
    Last Post: 11-14-2017, 10:19 AM
  5. Formula to Unify Text Entries in the Same Column
    By Taisir in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 12-22-2015, 03:01 AM
  6. Various date formats in same column
    By mardiefe in forum Excel General
    Replies: 5
    Last Post: 06-22-2014, 09:42 AM
  7. Trying to unify multiple different formats of phone numbers
    By Chanu in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-21-2013, 03:16 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