+ Reply to Thread
Results 1 to 10 of 10

Date format issues

  1. #1
    Registered User
    Join Date
    10-28-2020
    Location
    Switzerland
    MS-Off Ver
    365
    Posts
    3

    Date format issues

    Hi I am having problems with one column of dates whereby some are in date format and others visually appear to be but are not. I know they are not as when I create a separate column and try to extract the =YEAR(A1), only those cells which are in fact date format show the correct result. If I format the column of dates as a date, and then try to extract the year, I still get multiple failures returning "VALUE". I have noticed that the values that fail are ones with single digit months i.e. 6-06-2020 instead of 06-06-2020.

    The file is extracted from a database which has thousands of lines and is formatted as an excel table, I have attached a small sample group in this file.

    Any help would be greatly appreciated.
    Thanks
    Attached Files Attached Files
    Last edited by SwissGoat; 10-29-2020 at 10:12 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Date format issues

    One way:

    =IFERROR(YEAR(A2),--RIGHT(A2,4))

    In CH, you may need ; as the separator.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    10-28-2020
    Location
    Switzerland
    MS-Off Ver
    365
    Posts
    3

    Re: Date format issues

    Thanks Glenn, you saved me hours of work

  4. #4
    Forum Contributor
    Join Date
    08-26-2016
    Location
    UK
    MS-Off Ver
    O365
    Posts
    260

    Re: Date format issues

    Quote Originally Posted by SwissGoat View Post
    The file is extracted from a database which has thousands of lines and is formatted as an excel table
    How have you done this; usually a small change in how this is done will allow us to get reliable full dates from such a database.
    As an aside - have you considered getting the data in via Power Query (Data tab, Get & Transform etc.)?

  5. #5
    Registered User
    Join Date
    10-28-2020
    Location
    Switzerland
    MS-Off Ver
    365
    Posts
    3

    Re: Date format issues

    Hi, I now have the same problem but now with the month as some have two characters and some have one, so the left formula cannot work as the format is not uniform in the cells. Can anyone help again with that?

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Date format issues

    once again, post a representative sample.

  7. #7
    Forum Contributor
    Join Date
    08-26-2016
    Location
    UK
    MS-Off Ver
    O365
    Posts
    260

    Re: Date format issues

    Since you didn't feel inclined to answer my previous questions…
    Select the cells with the putative dates in and run this macro:
    Please Login or Register  to view this content.
    This will leave the numbers as they are and convert the strings to real, full, Excel dates.
    Then format the whole column as dates which will have those numbers showing as dates too.

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,730

    Re: Date format issues

    Using your original sample and Power Query

    Here is the Mcode and file for your review.
    Please Login or Register  to view this content.
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  9. #9
    Valued Forum Contributor Dunc3142's Avatar
    Join Date
    09-05-2007
    Location
    Franklin OH
    MS-Off Ver
    2000 and 2007 and 2010 @ Home & Teach 2010
    Posts
    351

    Re: Date format issues

    Excel doesn't like dash - as date separators do a replace find - replace with / and the original formula works.
    Yes it will. we just have to figure out how...
    If I have helped you, PLEASE click the * and add to my Rep.
    Also, if the problem is SOLVED please mark it as so.

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

    Re: Date format issues

    Try:
    Please Login or Register  to view this content.
    Quang PT

+ 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. Date format issues
    By Vihral in forum Excel General
    Replies: 2
    Last Post: 03-06-2019, 03:36 AM
  2. [SOLVED] Date format from textbox to filter - text to date formate issues
    By Wales MB in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-26-2015, 07:36 AM
  3. [SOLVED] UK and USA Date Format Issues - Userform
    By Mousiefuzz in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-12-2015, 07:48 AM
  4. Date format issues
    By robertrocks in forum Excel General
    Replies: 2
    Last Post: 11-05-2010, 01:32 PM
  5. Date format issues
    By sketchgal in forum Excel General
    Replies: 2
    Last Post: 07-20-2010, 07:33 AM
  6. date format/charting issues
    By Monty in forum Excel General
    Replies: 1
    Last Post: 04-18-2006, 02:20 PM
  7. date format issues
    By freekrill in forum Excel General
    Replies: 2
    Last Post: 02-16-2005, 07:52 PM

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