Thread: LEFT formula
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Joe User[_2_] Joe User[_2_] is offline
external usenet poster
 
Posts: 905
Default LEFT formula

"Fats" wrote:
=IF(LEFT(D103,10)=LEFT(E103,10),"1","")
D103 is a link to a MS Project file cell containing a
date and time - eg. "13/09/2010 11:00:00 AM".
E103 is a date - eg. "13/09/2010".

[....]
Can any one see my error or offer a better formula
to get the result I am after?


Sometimes, the solution is easier to understand than the explanation. At a
minimum, try:

=if(int(D103) = E103, "1", "")

But why are you returning 1 as a string? I suspect you really (should) want:

=if(int(D103) = E103, 1, "")

As for the explanation....

Remember that what is displayed in the cell is often the cell's true value.
Formats affect the appearance, not the value. For example, the Accounting
format causes a dollar sign and commas to appear (based on my regional
settings; you might see other characters). But those characters are not part
of the value of the cell.

Likewise, the Date and Time formats (as well as related Custom formats)
merely affect the appearance of the cell value.

But in fact, dates are stored as integers representing the number of
calendar days since 12/31/1899; for example, 13 Sep 2010 is the number 40434.
Time is stored as a fraction of a day; for example, noon is 0.5.

With that in mind, if you enter the formulas =LEFT(D103,99) and
=LEFT(E103,99), you will gain some insight into why your formula does not
work.

Alternatively, format D103 and E103 as General or Number with some number of
decimal places to see their true values.

INT(D103) captures the date part of the date/time value. We could also
write INT(E103). But that is unnecessary since you said E103 contains only a
date; thus, time is 0:00:00 AM, which is a decimal fraction of zero. In
other words, E103 is the same value as INT(E103).


----- original message -----

"Fats" wrote:
Hello,

Need some assistance on the following:

=IF(LEFT(D103,10)=LEFT(E103,10),"1","")

D103 is a link to a MS Project file cell containing a date and time - eg.
"13/09/2010 11:00:00 AM". E103 is a date - eg. "13/09/2010".

The above formula should produce "1" when the first 10 characters match. How
ever it does not. Can any one see my error or offer a better formula to get
the result I am after?

Thanks for your help in advance.

Ant.
--
Cheers
Ant.