+ Reply to Thread
Results 1 to 14 of 14

Reshaping date format

  1. #1
    Registered User
    Join Date
    02-27-2018
    Location
    Washington
    MS-Off Ver
    10
    Posts
    5

    Question Reshaping date format

    Hi everyone.

    I would like to build a code that transforms my current format into a desired format for my dates. Both formats should be kept as General. Please find below some examples:

    Current format: 1/1/2018 12:00:00 AM
    Target format: All : [1/1/2018,2/1/2018)

    Current format: 2/1/2018 12:00:00 AM
    Target format: All : [2/1/2018,3/1/2018)

    Current format: 10/1/2018 12:00:00 AM
    Target format: All : [10/1/2018,11/1/2018)


    In the target format I add some text, ignore the 12:00:00 AM part, and include in bracket current month and next month.

    I would really appreciate your help to build this formula.

    Thank you.

    David
    Attached Files Attached Files

  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 2403
    Posts
    44,194

    Re: Reshaping date format

    Try this:

    ="All: ["&TEXT(B3,"m/d/yyyy")&","&TEXT(EDATE(B3,1),"m/d/yyyy")&")"

    differences between USA date formats and the way everyone else records dates makes it difficult for me to replicate your source data!!
    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
    02-27-2018
    Location
    Washington
    MS-Off Ver
    10
    Posts
    5

    Re: Reshaping date format

    Hi Glenn,

    It worked, thank you very much. I have been living in the US for 3 years and still have a hard time reading dates

    David

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Reshaping date format

    another way with PowerQuery
    (it doesn't work without PowerQuery add-in)
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-27-2018
    Location
    Washington
    MS-Off Ver
    10
    Posts
    5

    Re: Reshaping date format

    Hi all,

    Thank you very much. I have another question, do you how I could build a formula that does the opposite thing? From All : [1/1/2018,2/1/2018) to 1/1/2018 12:00:00 AM.

    Thank you again.

    David

  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 2403
    Posts
    44,194

    Re: Reshaping date format

    You're welcome.



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

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  7. #7
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Reshaping date format

    here is
    as before, done with PowerQuery
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-27-2018
    Location
    Washington
    MS-Off Ver
    10
    Posts
    5

    Re: Reshaping date format

    Thank you Sandy. I need to use this code inside a vlookup formula, do you know how I could see those steps you did with PowerQuery in a single Excel formula?

    Thanks again.

    David

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Reshaping date format

    Here is Master of Formula, Glenn and probably he will give you a very good solution

  10. #10
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Reshaping date format

    but you can try this one
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and custom format d/m/yyyy hh:mm AM/PM

    or this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sandy666; 02-27-2018 at 05:52 PM. Reason: file updated

  11. #11
    Registered User
    Join Date
    02-27-2018
    Location
    Washington
    MS-Off Ver
    10
    Posts
    5

    Re: Reshaping date format

    Hi Sandy,

    Thank you very much. I think there is an added difficulty; both in the source and the result, dates with single digits are not displayed with a zero in front, so it is 1/1/2018 and not 01/01/2018. That makes it more complex because you may have one and two digit months, and using the MID function gives you different results depending on that.

  12. #12
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Reshaping date format

    so try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    or easier
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    because 8 is constant (in this case) which is the position of the first character of required string

    All : [1/1/2018,2/1/2018) 7 + 1 ==> 8
    Last edited by sandy666; 02-27-2018 at 07:44 PM.

  13. #13
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,410

    Re: Reshaping date format

    Similar to sandy's approach.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and then format accordingly. (m/d/yyyy h:mm AM/PM)



    D
    E
    3
    All : [1/1/2018,2/1/2018)
    1/1/2018 12:00 AM
    4
    All : [2/1/2018,3/1/2018)
    2/1/2018 12:00 AM
    5
    All : [10/1/2018,11/1/2018)
    10/1/2018 12:00 AM
    Dave

  14. #14
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2021
    Posts
    5,930

    Re: Reshaping date format

    Or try:

    =--TRIM(MID(SUBSTITUTE(SUBSTITUTE(D3,"[",","),",",REPT(" ",100)),100,100))

+ 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. Converting from the 1904 date format to the 1900 date format without losing data
    By Patty McJorst in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-01-2020, 12:53 PM
  2. Reshaping data into panel data format
    By migftg95 in forum Excel General
    Replies: 1
    Last Post: 02-27-2018, 04:53 PM
  3. Problem with Reshaping Excel data for Stata use.
    By alex54 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-07-2014, 10:56 AM
  4. Replies: 5
    Last Post: 02-08-2013, 11:06 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. Reshaping Data
    By GQuinn in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-21-2010, 11:41 PM
  7. Reshaping a matrix/text array
    By jesiotr in forum Excel General
    Replies: 1
    Last Post: 01-31-2008, 08:19 AM

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