+ Reply to Thread
Results 1 to 13 of 13

modify date time cell to an excel format date time

  1. #1
    Registered User
    Join Date
    03-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    modify date time cell to an excel format date time

    Hi All, I import data into excel on a regular basis in a csv format. However when the timestamp is imported it is in a format in which excel cannot recognize.
    It looks like this
    2012-07-19T23:00:01.01+10
    or like this
    2012-07-19T23:15:01+10 (milliseconds not in format this time!)
    which is year month day hour minutes seconds/milliseconds + gmt offset
    I don't need the gmt offset or the seconds or milliseconds which sometimes are not even present.
    I have very little excel skill and its way above me. I have been able to strip it down using text to columns but this then puts it into two columns one with the date, the other with the time
    Ideally I would like to click on the column and convert all the cells in that column to an excel date/time format or it happen automatically as I import the data
    The timestamp is always the A column when imported.
    I use a web query like this to import the data http://dbname/archive/fetch?swid=/U4...t/plain&after= 2012-01-01T00:00)
    Any help would be much appreciated.
    cheers rileyp
    Last edited by rileyp; 03-18-2013 at 02:12 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    04-03-2012
    Location
    East Sussex, UK
    MS-Off Ver
    Excel 2003:2010
    Posts
    893

    Re: modify date time cell to an excel format date time

    One way of doing this would be using the below formula in a blank cell on the same row and copying down.
    You could then use paste special values to paste the new column back over the original.

    =DATE(LEFT(A1,4),MID(A1,6,2),MID(A1,9,2))+TIME(MID(A1,12,2),MID(A1,15,2),0)

    It's not a perfect solution, but it can be expanded upon.
    If I've been of help, please hit the star

  3. #3
    Registered User
    Join Date
    03-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: modify date time cell to an excel format date time

    Thanks so much for the fast and comprehensive reply. I'll give it try.

    cheers rileyp

    Edit. It works perfectly.
    Thanks
    Edit 2 I'd like to hit the star.. but where?
    Last edited by rileyp; 03-17-2013 at 08:58 AM.

  4. #4
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: modify date time cell to an excel format date time

    Hi

    Another way with the data you supplied in post #1. assuming your data is in column A, in B1 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Format the cells as "dd/mm/yyy hh:mm" or whatever you require.
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  5. #5
    Registered User
    Join Date
    03-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: modify date time cell to an excel format date time

    Hi Kevin
    Thank you so much as well!
    I tried your method as I would prefer in dd/mm/yyy hh:mm and I can get it to mm/dd/yyy hh:mm from the format cells drop down list but the option for dd/mm/yyy hh:mm isnt there so again eludes me. I am a novice of excel so I do apologise.

  6. #6
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: modify date time cell to an excel format date time

    Hi rileyp

    Select the cells to format, CTRL + 1 on the keyboard to call up the Format Cells dialogue box > Number Tab > Custom > Then in Type: "dd/mm/yyy hh:mm" (without the quotes") > OK

    Format Cells.PNG

  7. #7
    Registered User
    Join Date
    03-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: modify date time cell to an excel format date time

    Thanks again. It works a treat.

  8. #8
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: modify date time cell to an excel format date time

    rileyp

    No problem and thanks for the feed back.

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: modify date time cell to an excel format date time

    Quote Originally Posted by Kevin UK View Post
    Hi

    Another way with the data you supplied in post #1. assuming your data is in column A, in B1 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Format the cells as "dd/mm/yyy hh:mm" or whatever you require.
    You can eventually omit the double unary operator (--) in this case, the arithmetic operators will coerce the strings to numbers

  10. #10
    Registered User
    Join Date
    03-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: modify date time cell to an excel format date time

    Hi all I'm back again I have it working and am now in the process of making a macro to perform this task automagically.
    I have run aground in getting it to select all the cells in the column automatically as it changes with each import.
    From my script below you can see its selects c2688 when I drop to the bottom using ctrl +the down arrow key.
    Is there a keyboard solution for this or must I use special code in my macro?
    Any help much appreciated once again.
    cheers rileyp
    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    04-03-2012
    Location
    East Sussex, UK
    MS-Off Ver
    Excel 2003:2010
    Posts
    893

    Re: modify date time cell to an excel format date time

    Hi rileyp,

    I've not messed around with your code too much. Just got rid of a couple of dead lines and added an 'offset' to account for the changes in row numbers for each import. Hopefully this should do what you need now.

    Personally I'd have defined the last row and used that to dictate which cells should have the formula pasted into, but I'm by no means a VBA expert so didn't want to go changing all of your code for something you might not be familiar with.

    S.


    Please Login or Register  to view this content.

  12. #12
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: modify date time cell to an excel format date time

    New question = new thread - Please ask a mod to move it for you

  13. #13
    Registered User
    Join Date
    03-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: modify date time cell to an excel format date time

    Spencer101
    Thanks very much for your help.
    Pepe I will ask a mod....Thanks.
    cheers rileyp

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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