+ Reply to Thread
Results 1 to 4 of 4

When a timestamp doesn't behave as a timestamp

  1. #1
    Registered User
    Join Date
    03-04-2011
    Location
    Vancouver, BC, Canada
    MS-Off Ver
    Excel 2007
    Posts
    2

    When a timestamp doesn't behave as a timestamp

    I have a long column of data from an Access dump and part of the timestamp cell values are "proper" in that they are really decimal values beneath the date/time formatting while others are just a string of characters that appear to be a timestamp at first glance.

    Am I making any sense to anyone? This "issue" escapes my ability to describe it.

    You can see a working example on Google Docs at this link.

    For lack of words: In column A I have:

    Row 1: 02/01/2011 2:20:00 AM
    Row 2: 1/31/2011 8:05:00 AM

    When I apply a decimal format to the two I get:

    Row 1: 40545.0972222222
    Row 2:1/31/2011 8:05:00 AM

    See that Row 2 doesn't change from date/time format to decimal. It just stays a "dumb" string.

    Wha??? Any ideas?

    Thanks

    Matthew

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: When a timestamp doesn't behave as a timestamp

    Let's use a "trick" to convert all those text strings into the same Excel decimal date.time values.

    1) Highlight the column
    2) Select Data > Text To Columns > Delimited > Next > Next
    3) On the 3rd screen, select DATE in the upper right corner and set the correct MDY or DMY or whatever it SHOULD be.
    4) Click OK.

    That should do it.

    Now the problem. I don't know if you noticed, but the FIRST row converted but probably converted incorrectly. If your computer's default date format is DMY, then the string converts to the number you gave in example 2 and that date string is actually Jan2,2011, not Feb1,2011.

    That's also why the second string doesn't convert, because there is no 31st month. So Excel assumes it's text and leaves it.

    So it's up to you when doing the trick I gave you to set the DMY or MDY to what the DATA is, not what you want the display to be. Convert it based on the data so it all converts, which in your sample appears to be MDY. Then set the display to what you want once it's all converted.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    03-04-2011
    Location
    Vancouver, BC, Canada
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: When a timestamp doesn't behave as a timestamp

    Jerry

    That's a nifty trick but I'm looking for a solution to the original problem. Doesn't appear quirky that this is happening? I'm having the same problem with a data extraction from a Hobo motor state logger. Some of the timestamps are "dumb" and the others are fine.

    Matthew

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: When a timestamp doesn't behave as a timestamp

    The reason why some are converting and some dont (as Jerry said) is that your excel is set to look at dates in the format of Day/Month/Year whereas these values are being imported as Month/Day/Year. So as far as Excel is concerned, if the second value is greater than 12, it's not a date.

    02/01/2011 (Feb 1) was seen by excel as Jan 2nd, no problem.
    1/31/2011 (Jan 31) is undecipherable to Excel because it's looking for the 1st of the 31st month.
    Did that help?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ 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