+ Reply to Thread
Results 1 to 9 of 9

Convert string date format to actual date range

  1. #1
    Registered User
    Join Date
    08-05-2014
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    4

    Convert string date format to actual date range

    Hi,

    Is there any way to convert a string date range such as "44663 - 44704" to its actual date range? Thanks.

    Ros

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,460

    Re: Convert string date format to actual date range

    Something like =TEXT(VALUE(LEFT(cell,5)),"mm/dd/yyyy")&" - "&TEXT(VALUE(RIGHT(cell,5)),"mm/dd/yyyy"). Replace "mm/dd/yyyy" with your favorite date format code.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

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

    Re: Convert string date format to actual date range

    You would have to split the column using Text to Columns using the delimiter "-" . Then multiply each cell by 1 to convert to number. Then format as a date. Next you will need to concatenate the two cells of Date information.

    EDIT: Or simply apply the formula supplied by MrShorty
    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

  4. #4
    Registered User
    Join Date
    08-05-2014
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    4

    Re: Convert string date format to actual date range

    Thank you, MrShorty and Alan!!!

    Ros

  5. #5
    Registered User
    Join Date
    08-05-2014
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    4

    Re: Convert string date format to actual date range

    Hi again,

    Sorry, now I ran my data and found out there are some with more than one Date string within one cell such as 44624 - 44635, 44683 - 44697, 44702 - 44706. Is there a way to convert it to actual date ranges within one cell or I have to split it to 3 cells before convert it? I would like to have it converted within one cell. Thanks.

    Ros

  6. #6
    Registered User
    Join Date
    07-22-2022
    Location
    Surabaya, Indonesia
    MS-Off Ver
    365
    Posts
    14

    Re: Convert string date format to actual date range

    Quote Originally Posted by helam View Post
    Hi again,

    Sorry, now I ran my data and found out there are some with more than one Date string within one cell such as 44624 - 44635, 44683 - 44697, 44702 - 44706. Is there a way to convert it to actual date ranges within one cell or I have to split it to 3 cells before convert it? I would like to have it converted within one cell. Thanks.

    Ros
    =TEXTJOIN(CHAR(10),TRUE,TEXT(LEFT(FILTERXML("<x><y>"&SUBSTITUTE(A11,", ","</y><y>")&"</y></x>","//y"),FIND(" - ",FILTERXML("<x><y>"&SUBSTITUTE(A11,", ","</y><y>")&"</y></x>","//y"),1)),"dd mmm yyyy")&" -"&TEXT(RIGHT(FILTERXML("<x><y>"&SUBSTITUTE(A11,", ","</y><y>")&"</y></x>","//y"),LEN(FILTERXML("<x><y>"&SUBSTITUTE(A11,", ","</y><y>")&"</y></x>","//y"))-FIND(" - ",FILTERXML("<x><y>"&SUBSTITUTE(A11,", ","</y><y>")&"</y></x>","//y"),1)-2),"dd mmm yyyy"))

    Replace A11 with your date range cell.
    Result will be generated in ONE cell by TEXTJOIN formula, delimited by char(10) / newline. Make sure you activated Wrap Text
    Too bad TEXTJOIN provided in Excel 2019 and later. Didn't knew your Excel version is update or not.
    And this formula designed to work for any serial date not only =5 characters but including <>5
    Best Regards,
    solusipembukuan.com
    +6287878935858

  7. #7
    Registered User
    Join Date
    08-05-2014
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    4

    Re: Convert string date format to actual date range

    Thank you!!!

    Ros

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

    Re: Convert string date format to actual date range

    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.

  9. #9
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,418

    Re: Convert string date format to actual date range

    Power Query
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. Convert forced change of date to String or Text format back to Date format in a column
    By analystbank in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-20-2022, 09:17 AM
  2. [SOLVED] Extracting a date from a text string and then need to convert to a date format.
    By ldborders in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-03-2021, 03:53 PM
  3. Convert numbers appearing as a date into actual date in order to sort data
    By Santa1986 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-06-2015, 12:56 PM
  4. [SOLVED] How to convert a set of string into date MM-YYYY format
    By Acan in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-30-2014, 06:29 AM
  5. Need Formula/VBA Code to convert date in String Format to Normal Date format
    By Karthik Sen in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-18-2012, 04:54 AM
  6. Convert date format from string to separator
    By masterp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-22-2006, 07:16 AM
  7. [SOLVED] Excel date format convert to string format
    By man in forum Excel General
    Replies: 1
    Last Post: 08-17-2006, 05:05 AM

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