+ Reply to Thread
Results 1 to 9 of 9

Date changes when I click in cell and use Enter key

  1. #1
    Registered User
    Join Date
    11-25-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    5

    Date changes when I click in cell and use Enter key

    I am downloading information from a database into XLSX. The source data has date / time fields. Some of the source data reads 12/31/13 11:59 PM.

    My end goal is for Excel to show 12/31/13 in those fields.

    When I download it, the date / time column formats itself as [$-409]mmm d, yyyy h:mm AM/PM.

    The date / time values is no longer 12/31/13 11:59 PM. Something changed...

    If I look at the spreadsheet the dates now read Jan 1, 2014 12:00 AM. If I apply any formula or format change to the cells, it always reads 1/1/14, never 12/31/13.

    But if I select one of those cells, in the formula bar it actually reads 12/31/2013 12:00:00 AM. (First question: why is this happening?)

    Now if my cursor is blinking in the cell and I hit the Enter key, the value in the spreadsheet changes to read Dec 31, 2013 12:00 AM.

    NOW if I reformat the cell, it will render as 12/31/13. (Second question: how can I make the cells render correctly as 12/31/13 without having to enter my cursor in thousands of cells and hit the Enter key? And I do not want to use VBA to do it.)

    Thanks -- Chris

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Date changes when I click in cell and use Enter key

    Have you tried using multiply?

    Enter a 1 into an empty cell. Copy that cell, highlight your range of data, right click, Paste Special..., and choose multiply.

    A better question might be: what is the actual value of your cells? Excel stores dates as the count of days since 1/1/1900 and time as a fraction of 1. If the stored value exceeds 15 digits, Excel could be rounding the value.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    11-25-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Date changes when I click in cell and use Enter key

    If I try the multiply by 1 paste trick, of course the format of the affected cells changes to number, and when I change it short date, it reads 1/1/2014 in the spreadsheet and 12/31/2013 12:00:00 AM in the formula bar. Effectively it doesn't change the problem.

    The underlying value of the cells is 41639.99999999 in the formula bar, but the cells read that as 41640.00. That never changes. It appears that Excel can't decide whether to round it up by .00000001 (in the cells) or leave it as is (as in the formula bar). If it rounds it up, the date is technically wrong.

    So the value doesn't change, it's the format of the cell that's acting squirrelly.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Date changes when I click in cell and use Enter key

    Ahh, there we go. Instead, use =LEFT(A1,11)*1

    The first 11 digits are the only ones needs for that level of time. The fractions of a second are throwing things off.

  5. #5
    Registered User
    Join Date
    11-25-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Date changes when I click in cell and use Enter key

    Actually let me qualify one thing: I noticed that if I change the format of the cells to number format, the number will read 41640.00 in the cell and 41639.9999999 in the formula bar...

    If I enter my cursor into the formula bar and just hit the Enter key, nothing changes at all. The value stays exactly the same. However...

    If I leave all the cells in the date format, and I repeat the above exercise, and THEN change back to the number format, the values have changed. The number in the cell changes to 41639.00, while in the formula bar it changes to 41639 (no decimals).

    So the date format of the cell will truncate the value of the cell after I engage the formula bar with the cursor. If I don't, it rounds up to the nearest whole.

    There seems to be a glitch in how Excel decides whether to round date / times to the minute.

    It also might be worthy to note that if I download the data into CSV the values are exact and correct and do not have an issue, but I can't use CSV due to some other problems with other fields.

  6. #6
    Registered User
    Join Date
    11-25-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Date changes when I click in cell and use Enter key

    Yes, =LEFT(A1,11)*1 does work, also TRUNC(J248) will work.

    But I had hoped I wouldn't have to apply formulas to the data. At any rate it may be my only hope.

  7. #7
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Date changes when I click in cell and use Enter key

    The issue is the great accuracy of your output, which is showing the milliseconds.

    You should be able to change the format of the entire range to custom format:

    mm/dd/yyyy hh:mm:ss.000

    to make it display correctly.
    Last edited by daffodil11; 11-26-2013 at 12:04 PM.

  8. #8
    Registered User
    Join Date
    11-25-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Date changes when I click in cell and use Enter key

    There you go! That's the magic I was looking for. I wasn't sure how to make the date format more definitive like that. Thanks for your help.

  9. #9
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Date changes when I click in cell and use Enter key

    Thanks for posting the issue. Up until that point I had no idea Excel even had a format to deal with milliseconds.


+ 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. Single click cell to enter text?
    By lsteinbach in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2013, 12:16 PM
  2. [SOLVED] Double-click cell to enter TODAY ()
    By Tanyab in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-12-2013, 05:43 AM
  3. Click to enter date when toggle button is depressed
    By kevinezra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2013, 12:28 AM
  4. Enter Text in Cell on Click
    By Steven Drenker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2006, 05:25 PM
  5. Replies: 4
    Last Post: 09-29-2005, 08:05 AM

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