+ Reply to Thread
Results 1 to 8 of 8

Convert Multiple Date Formats Into Standard Format

  1. #1
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Convert Multiple Date Formats Into Standard Format

    Hello,

    I am always receiving list of date of birth where I have to calculate age but due to improper format (List Below) it is taking lost of time. the list of DOB sometimes more than 20,000 to 25,000

    I am just wondering if any one can help me to convert multiple date formats Hijri (Arabic) and Gregorian (Non-Standard) into MM-DD-YYYY.

    Date Formats Are Listed Below:-
    Please Login or Register  to view this content.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Convert Multiple Date Formats Into Standard Format

    Some of this may be able to be accomplished by pattern matching, but the issue is that some date formats are ambiguous, especially those that are either mm-dd or dd-mm or some other combination of month and day.

    For example 4/5/2016 can be either April 5th, 2016 or May 4th, 2016. Obviously 13/5/2016 is May 13th as is 5/13/2016. But there are 144 ambiguous dates (the first 12 days of the 12 months).
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Re: Convert Multiple Date Formats Into Standard Format

    Thanks for the reply.

    90% of my work will be on year and month or day not matters. if you see the list it has only year also (1955). I was just wondering if the format will be standard i.e. dd-mm-yyyy. the purpose is for this request to calculate the age from Date of Birth.

    So most of the request will have year.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Convert Multiple Date Formats Into Standard Format

    Under these conditions, the best I can do is get the year for you. I included a few formats that you didn't include such as variations of mm/dd/yyyy and m/d/yyyy. Where the month or day can be either one or two digits. The function works on matching patterns using the VBA LIKE function.

    One surprise I had is that the default condition, meaning do this if none of the other patterns match is Year(Date). The first surprise was that I am passing a string that looks like a number (to cover your General case) and it still interpreted it as a date. The other surprise is I passed it mm/dd/yy and it also interpreted it as a date. However, I was planning on programming some "windowing" to determine if the YY was in the 20th or 21st century. YEAR() figured it out for me. I think what it is doing is if the last two digits of the year are greater than the current year, it is the 1900's otherwise the 2000's.

    Obviously dates in the 1400's are Hijri dates otherwise Common Era. I do not know how to convert between the two date systems.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Re: Convert Multiple Date Formats Into Standard Format

    Thanks for the solution. Is their any way which we can return the format like dd-mm-yyyy instead of date to cross check with the original data. because at last I have to crosscheck with the data even after the conversion of the date.

    that is why I have mentioned in my first post to convert multiple format to dd-mm-yyyy.

    Can it be possible.

  6. #6
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Re: Convert Multiple Date Formats Into Standard Format

    Thanks for the solution. Is their any way which we can return the format like dd-mm-yyyy instead of date to cross check with the original data. because at last I have to crosscheck with the data even after the conversion of the date.

    that is why I have mentioned in my first post to convert multiple format to dd-mm-yyyy.

    Can it be possible.

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Convert Multiple Date Formats Into Standard Format

    I can't get the days and months since some formats are dd/mm and others are mm/dd and I can't tell from the information given which format is intended.

    If one of the numbers is greater than 12, then I know that it's the day and the other one must be the month, but that still leaves 132 cases where I can get it wrong (The first 12 days of the 12 months = 144 minus where the day equals the month in which case it doesn't matter.)

  8. #8
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Re: Convert Multiple Date Formats Into Standard Format

    See the result which I am looking for. Original date list in column A and after running the vba macros the output date format in column B and age in column C.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ 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] How to convert date format "20150501" to standard date format "01-MAY-15"
    By kartsag09 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-20-2016, 12:54 PM
  2. Replies: 19
    Last Post: 01-31-2016, 12:29 PM
  3. Replies: 5
    Last Post: 02-08-2013, 11:06 AM
  4. Converting all date formats to one single standard format.
    By booo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-25-2010, 07:14 PM
  5. Replies: 5
    Last Post: 10-18-2010, 05:54 AM
  6. Convert dates like 2007.15 into standard format
    By Deviad in forum Excel General
    Replies: 9
    Last Post: 05-11-2010, 08:02 AM
  7. [SOLVED] how do i convert standard time format into seconds?
    By Raj in forum Excel General
    Replies: 4
    Last Post: 05-29-2006, 12:00 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