+ Reply to Thread
Results 1 to 12 of 12

Working with Date and Time Issues

  1. #1
    Registered User
    Join Date
    01-27-2012
    Location
    Berkeley, California
    MS-Off Ver
    Excel 2016
    Posts
    33

    Working with Date and Time Issues

    I have a dataset of recorded water levels and the data comes in with the date and time all in one cell as follows:

    2021-12-06T23:30:00Z 105.592
    2021-12-06T23:40:00Z 105.635
    2021-12-06T23:50:00Z 6.448
    2021-12-07T00:00:00Z 6.475

    I need to separate out the date and the times so I can convert the times from UTC (the "Z" at the end means Greenwich Mean time) to subtract 7 hours to get to PDT (Pacific time) where the data is being collected. Also to get rid of the "T" that separates the time. Ideally they can be separates into separate data columns but I need to be able to adjust the time by 7 hours to match local time.

    a sample of the data is attached.

    thanks, Roger
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,347

    Re: Working with Date and Time Issues

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


    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


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

    Re: Working with Date and Time Issues

    Because this seems to be becoming a standardized time stamp, I'm hopeful that MSFT will see fit to program Excel so it will automatically recognize this kind of time stamp in some future version. Until then, Excel will recognize this kind of time stamp if you can get rid of the T and Z characters. I would:
    1) Import the text to Excel.
    2) Find/Replace T with space, Z with comma (or other convenient delimiter character).
    3) Text to columns -> delimited (by comma or whatever character you chose in step 2) -> At the appropriate step, make sure that Excel knows that this is YMD date data -> finish text import wizard.

    Excel should correctly recognize the data/time stamp and convert to a number (formatted in whatever default date/time format Excel chooses). That will leave your UTC date/time together in the same cell. Then you can add a helper column to convert to your desired time zone by adding or subtracting the appropriate value =UTCtime-TIME(7,0,0).
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

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

    Re: Working with Date and Time Issues

    Here is an alternative with Power Query to put in a standard Date Time US format.

    Please Login or Register  to view this content.
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.

    Excel 2016 (Windows) 64 bit
    A
    B
    C
    D
    E
    F
    G
    H
    1
    Montrezuma Pile
    2
    Date STG STG-Unit Date STG STG-Unit Custom
    3
    2021-12-06T23:30:00Z
    105.592
    ft
    12/6/2021 23:30
    105.592
    ft
    12/6/21 4:30 PM
    4
    2021-12-06T23:40:00Z
    105.635
    ft
    12/6/2021 23:40
    105.635
    ft
    12/6/21 4:40 PM
    5
    2021-12-06T23:50:00Z
    6.448
    ft
    12/6/2021 23:50
    6.448
    ft
    12/6/21 4:50 PM
    6
    2021-12-07T00:00:00Z
    6.475
    ft
    12/7/2021 0:00
    6.475
    ft
    12/6/21 5:00 PM
    7
    2021-12-07T00:10:00Z
    6.491
    ft
    12/7/2021 0:10
    6.491
    ft
    12/6/21 5:10 PM
    8
    2021-12-07T00:20:00Z
    6.502
    ft
    12/7/2021 0:20
    6.502
    ft
    12/6/21 5:20 PM
    9
    2021-12-07T00:30:00Z
    6.492
    ft
    12/7/2021 0:30
    6.492
    ft
    12/6/21 5:30 PM
    10
    2021-12-07T00:40:00Z
    6.469
    ft
    12/7/2021 0:40
    6.469
    ft
    12/6/21 5:40 PM
    11
    2021-12-07T00:50:00Z
    6.433
    ft
    12/7/2021 0:50
    6.433
    ft
    12/6/21 5:50 PM
    12
    2021-12-07T01:00:00Z
    6.36
    ft
    12/7/2021 1:00
    6.36
    ft
    12/6/21 6:00 PM
    13
    2021-12-07T01:10:00Z
    6.263
    ft
    12/7/2021 1:10
    6.263
    ft
    12/6/21 6:10 PM
    14
    2021-12-07T01:20:00Z
    6.139
    ft
    12/7/2021 1:20
    6.139
    ft
    12/6/21 6:20 PM
    15
    2021-12-07T01:30:00Z
    5.982
    ft
    12/7/2021 1:30
    5.982
    ft
    12/6/21 6:30 PM
    16
    2021-12-07T01:40:00Z
    5.819
    ft
    12/7/2021 1:40
    5.819
    ft
    12/6/21 6:40 PM
    17
    2021-12-07T01:50:00Z
    5.623
    ft
    12/7/2021 1:50
    5.623
    ft
    12/6/21 6:50 PM
    18
    2021-12-07T02:00:00Z
    5.412
    ft
    12/7/2021 2:00
    5.412
    ft
    12/6/21 7:00 PM
    19
    2021-12-07T02:10:00Z
    5.206
    ft
    12/7/2021 2:10
    5.206
    ft
    12/6/21 7:10 PM
    20
    2021-12-07T02:20:00Z
    5.057
    ft
    12/7/2021 2:20
    5.057
    ft
    12/6/21 7:20 PM
    Sheet: fts-data_2019-10-23T09_21_00.00
    Last edited by alansidman; 03-30-2024 at 10:56 AM.
    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

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,347

    Re: Working with Date and Time Issues

    Following Alan's description, you can also try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


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

  6. #6
    Registered User
    Join Date
    01-27-2012
    Location
    Berkeley, California
    MS-Off Ver
    Excel 2016
    Posts
    33

    Re: Working with Date and Time Issues

    Thanks Trevor

    This worked great and seems like the simplest approach although I am sure PowerQuery answers below works great, I may need more time to learn how to work with it.

    One more request, your fix took care of the time part but how can I separate out the date into its own column without the time? This way to have date and time separated out into separate columns

    thanks, Roger

  7. #7
    Registered User
    Join Date
    01-27-2012
    Location
    Berkeley, California
    MS-Off Ver
    Excel 2016
    Posts
    33

    Re: Working with Date and Time Issues

    Actually, the convert text to columns part isnt working for me. Sorry to be Excel lame but did the substitute formula as suggested but it both doesn't change date correctly also when I try the text to columns function, it doesn't work, it just breaks the formula. I am sure I am doing something but looking for a simple way to separate out date from time into separate columns in order to analyze the water level tide data. Attached is an updated spreadsheet with the formulas I tried form this thread.

    thank you for your assistance
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,763

    Re: Working with Date and Time Issues

    Are you still using Excel 2016?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,763

    Re: Working with Date and Time Issues

    If you have Excel 365 now, try this copied down:

    =IFERROR(--TEXTSPLIT(A3,{"T","Z"}),"")
    Attached Files Attached Files

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,763

    Re: Working with Date and Time Issues

    For Excel 2016:

    =--LEFT(A3,FIND("T",A3)-1)

    and:

    =--MID(A3,FIND("T",A3)+1,8)

    Copy down.
    Attached Files Attached Files

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,347

    Re: Working with Date and Time Issues

    You can just take the individual elements, given they are fixed length.

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

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

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

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

    Re: Working with Date and Time Issues

    Updated PQ Mcode to show split of Date and Time
    Please Login or Register  to view this content.

+ 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. Replies: 1
    Last Post: 11-11-2019, 10:04 AM
  2. [SOLVED] Time and Date Forumla Issues
    By randomfluky in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-20-2013, 04:54 AM
  3. [SOLVED] date and time issues!
    By brucey2343 in forum Excel General
    Replies: 7
    Last Post: 09-15-2013, 11:19 PM
  4. [SOLVED] time date formatting issues
    By Davis.Gray in forum Excel General
    Replies: 7
    Last Post: 08-06-2013, 04:25 PM
  5. Date and Time Issues
    By ScottL in forum Excel General
    Replies: 1
    Last Post: 11-29-2011, 02:07 PM
  6. Date and Time issues
    By Kypsis in forum Excel General
    Replies: 2
    Last Post: 12-02-2010, 04:16 PM
  7. Time & Date format issues
    By amblipo in forum Excel General
    Replies: 0
    Last Post: 01-05-2005, 06:47 PM

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