having a problem with the date formula

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
768
In col A I have the date and time together. For example:

1/05/2019 8:09:22 PM

In col B I wanted just the date, so I wrote a formula: =LEFT(A2,10)

I'm not getting "1/05/2019" the way I'd expect. Instead I'm getting 43470.8398

When I go to Short Date or Long Date I'm seeing the same result. If I go to Properties / Date it seems to be showing me day/month/year rather than the other way around. Dont know if that's related.

Can anyone advise?
 

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,334
The display of the cell is NOT the same as the "value" of the cell.

Date and time are stored as numbers but displayed with date formats. I suspect LEFT(A1,10) displays the first 10 digits of the numerical value of the date and time.

You can either:

Edit the cell format in A1 (select range, right click, Cell Formats, then custom) to "DD/MM/YYYY" (or "MM/DD/YYYY" if you're of US preference) and apply to the range.

Or in B1 use
Code:
=TEXT(A1, "DD/MM/YYYY")
It's like "$1000" vs "1,000" vs "One Thousand" vs 1000 - they are all the same numerical value, but displayed with different formats; i.e. the "meaning" or context is interpreted by User but the actual number is still just a number.
 
Last edited:

AlanY

Well-known Member
Joined
Oct 30, 2014
Messages
3,962
Office Version
365, 2019, 2016
Platform
Windows
excel store time in fraction of a day, i.e. 24 hrs.
in your example, 43470 for the date and .8398 for time.

if you just wanted date without time can use =INT() to rid of the time and format the cell as date
 
Last edited:

Nickaroo77

New Member
Joined
Jul 22, 2014
Messages
1
Hi Big Dan,

You could try using the following:

=TEXT(LEFT(B2,10),"dd/mm/yy")

Hope this helps!
 

Forum statistics

Threads
1,081,981
Messages
5,362,533
Members
400,679
Latest member
alecalec202

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top