+ Reply to Thread
Results 1 to 6 of 6

Help with transforming a string into date / time format

  1. #1
    Registered User
    Join Date
    10-17-2019
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    5

    Question Help with transforming a string into date / time format

    2020-06-26_11-43-01.png

    Basically I have a field which can either include a date/time string in

    dmmyyyyhhmm or ddmmyyyyhhmm depending on day of the month

    I'm trying to establish a function or formula I can use to transform that into

    yyyy-mm-dd hh:mm:ss

    The way the string is currently formed, Excel won't even recognise it as a date / time.
    Attached Files Attached Files
    Last edited by Mooklie; 06-26-2020 at 12:16 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Help with transforming a string into date / time format

    Using Power Query/Get and Transform, here is the Mcode to change your Date/Time Column

    Please Login or Register  to view this content.
    Review PQ
    In the attached file
    Click on any cell in the new table
    On the Data Tab, click on Queries & Connections
    In the right window, double click to open Query
    Review PQ steps

    M-code basics:
    - "let" is the start of a query
    - "in" is the closing of a query
    - each transformation step sits in between those 2 lines
    - each step line is ended by a comma, except the last one
    - "Source" is always the first step (Source Data)
    - After "in" you have the last step referenced

    Excel 2016 (Windows) 32 bit
    A
    B
    1
    Date Time Reading
    2
    2011-01-1 00:00
    1.329
    3
    2011-01-1 00:10
    1.324
    4
    2011-01-1 00:20
    1.322
    5
    2011-01-1 00:30
    1.334
    6
    2011-01-1 00:40
    1.35
    7
    2011-01-1 00:50
    1.38
    8
    2011-01-1 01:00
    1.414
    9
    2011-01-1 01:10
    1.455
    10
    2011-01-1 01:20
    1.504
    11
    2011-01-1 01:30
    1.563
    12
    2011-01-1 01:40
    1.631
    13
    2011-01-1 01:50
    1.708
    14
    2011-01-1 02:00
    1.795
    15
    2011-01-1 02:10
    1.886
    16
    2014-11-16 16:00
    1.153
    17
    2014-11-16 16:10
    1.29
    18
    2014-11-16 16:20
    1.425
    19
    2014-11-16 16:30
    1.562
    20
    2014-11-16 16:40
    1.699
    21
    2014-11-16 16:50
    1.833
    22
    2014-11-16 17:00
    1.954
    23
    2014-11-16 17:10
    2.082
    24
    2014-11-16 17:20
    2.208
    25
    2014-11-16 17:30
    2.328
    26
    2014-11-16 17:40
    2.447
    27
    2014-11-16 17:50
    2.567
    28
    2014-11-16 18:00
    2.69
    Sheet: Sheet1
    Attached Files Attached Files
    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

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Help with transforming a string into date / time format

    You can use this formula...

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and Custom Format is output using yyyy-mm-dd hh:mm for the Type pattern.
    Last edited by Rick Rothstein; 06-25-2020 at 11:56 PM.

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Help with transforming a string into date / time format

    Try this in D2:
    Please Login or Register  to view this content.
    Format cell as "yy-mm-dd hh:mm"

    If you don't want to format it and keep it as TEXT:
    Please Login or Register  to view this content.
    Quang PT

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Help with transforming a string into date / time format

    And if you want a macro to change the values directly within their cells...
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-17-2019
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    5

    Re: Help with transforming a string into date / time format

    Thanks to you both, this helped me A LOT - I had over 300,000 records and would have taken for ever to do it manually. I used bebo021999 fix but I'm sure all solutions would have worked great.

    Much appreciated.

+ 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] Converting Unusable Time / Date Format To Usable Time / Date Format
    By Gtrtim112 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-05-2019, 11:25 AM
  2. [SOLVED] Converting Date & Time (General format) to Date (Date format)
    By supremenuts in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2017, 12:55 PM
  3. transforming a long dataset into a wide format
    By dmunte in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 11:42 AM
  4. 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
  5. transforming raw data to new time format
    By gamuzadt in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 11-16-2009, 11:22 AM
  6. [SOLVED] Excel date format convert to string format
    By man in forum Excel General
    Replies: 1
    Last Post: 08-17-2006, 05:05 AM
  7. [SOLVED] transforming a date
    By [email protected] in forum Excel General
    Replies: 4
    Last Post: 08-01-2006, 12:15 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