Consulting

Results 1 to 6 of 6

Thread: Date Format Help

  1. #1
    VBAX Regular
    Joined
    Jan 2018
    Location
    Nova Scotia
    Posts
    83
    Location

    Date Format Help

    Hi All,
    This is probably a simple fix, but I'm stuck....

    I have a date & time one column, that I'd like separated into 1.) Date (example: March 14, 2001) and 2.) Time
    I just can't seem to get this working. Any help would be appreciated.

    Thx,
    Jim

    See attached
    Attached Files Attached Files

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,158
    Location
    For date maybe:

    =Text(A1,"dd/mm/yyyy")

    Time:

    =Text(A1,"hh:mm")

    Hope this helps
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2401, Build 17231.20084

  3. #3
    VBAX Regular
    Joined
    Jan 2018
    Location
    Nova Scotia
    Posts
    83
    Location
    It doesn't work. It just copies the exact same thing to the new columns. I'm trying to get date in one column and time in the other. The other problem is that the date 01/05/2018 isn't recognized as a date.

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,158
    Location
    Try this for date then:

    =TEXT(B2,"mmm dd, yyyy")

    This for time:

    =Text(B2,"hh:mm")

    If you want a date value then maybe:

    =TEXT(DATEVALUE(B2),"mm/dd/yyyy")
    =DATEVALUE(TEXT(B2,"mm/dd/yyyy"))

    Then format the cell to how you want a date to look
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2401, Build 17231.20084

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    It looks like the strings in Col A are

    DD/MM/YYYY space HH:MM:SS AM

    ????

    If so then you can try

    =TEXT(DATE(MID($B2,7,4), MID($B2,4,2), MID($B2,1,2)),"mmmm dd, yyyy")

    =TEXT(TIMEVALUE(RIGHT($B2,LEN($B2)-FIND(" ",$B2))),"hh:mm:ss AM/PM")
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  6. #6
    VBAX Regular
    Joined
    Jan 2018
    Location
    Nova Scotia
    Posts
    83
    Location
    Thank you Paul. It works perfectly.

    Jim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •