+ Reply to Thread
Results 1 to 9 of 9

Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    34

    Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

    Hi guys

    I have a column with dates in format mm-dd-yyyy and mm/dd/yyyy. I need a formula that converts either of them to dd-mm-yyyy.

    Right now I use =DATE(RIGHT(A4;4);LEFT(A4;2);MID(A4;4;2)) which works for mm/dd/yyyy but doesnt work for mm-dd-yyyy.

    Can anyone help?

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

    You could do it without a formula by selecting the column, going to Data>Text to columns... and selecting MDY for the column data format on the 3rd step.
    If posting code please use code tags, see here.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,667

    Re: Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

    in the first case you already have a date in the cell. To deal with such situation try:
    =IF(ISNUMBER(A2),A2,DATE(RIGHT(A2,3),LEFT(A2,2),MID(A2,4,2)))
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    01-04-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

    Quote Originally Posted by Kaper View Post
    in the first case you already have a date in the cell. To deal with such situation try:
    =IF(ISNUMBER(A2),A2,DATE(RIGHT(A2,3),LEFT(A2,2),MID(A2,4,2)))
    Hi again Kaper

    It works for some cells... however, with the cell 05/17/2012 it returns 17-05-1912 with your formula. are you able to fix that?

    Cheers

    Chris

  5. #5
    Registered User
    Join Date
    01-04-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

    Quote Originally Posted by ChristopherH View Post
    Hi again Kaper

    It works for some cells... however, with the cell 05/17/2012 it returns 17-05-1912 with your formula. are you able to fix that?

    Cheers

    Chris
    ie. this formula now has problems with dates mm/dd/yyyy

  6. #6
    Registered User
    Join Date
    01-04-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

    Quote Originally Posted by Norie View Post
    You could do it without a formula by selecting the column, going to Data>Text to columns... and selecting MDY for the column data format on the 3rd step.
    I'm not quite sure how this works. I can't get it to work.

    EDIT: I think it works now, however, I didnt choose MDY. thanks alot

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

    You should need to chose the format the dates are currently in, which is MDY.

    If you had to choose something else perhaps it's a locale setting.

  8. #8
    Registered User
    Join Date
    01-04-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

    Okay. Now with the convert to text and the formula =DATE(RIGHT(A1;4);LEFT(A1;2);MID(A1;4;2)) it works for most of the dates. However, with some of them it shows an error, I have no idea why? I'll upload example, its very strange.

    EDIT: solved it, its because it says 3/25/2013 and not 03/25/2013
    Attached Files Attached Files
    Last edited by ChristopherH; 01-29-2014 at 09:06 AM.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Need date formula to convert mm-dd-yyyy or mm/dd/yyyy to dd-mm-yyyy in 1 formula

    The dates have only have 1 digit for the month.

+ 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 Function: How to convert MM-DD-YYYY to DD-MM-YYYY
    By ramki in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-23-2014, 12:03 AM
  2. [SOLVED] How to Convert date format ( DD/MM/YYYY) into MM/YYYY
    By PRADEEPB270 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-04-2014, 07:25 AM
  3. [SOLVED] Imported data contains strings dd.mm.yyyy how can I convert to date format dd/mm/yyyy inVB
    By Boormo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-05-2012, 05:48 PM
  4. Copy+Paste macro dd/mm/yyyy to dd/mm/yyyy and NOT dd/mm/yyyy to mm/dd/yyyy
    By uimhirADo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2012, 03:45 AM
  5. Macro to convert dates format from yyyy mm dd to yyyy-mm-dd
    By Gators in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-26-2009, 02:23 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