"You can’t compare a date with a number" in a formula that worked in Excel

I opened in Numbers an invoice file which was created in Excel. Formula returns hours worked. It has an "if" condition for the date field. I am assuming that that is the reason I get this "You can’t compare a date with a number because their data types are different." What do I do?


Formula reads =IF(SUM(A11)>0,(D11−C11),"") where A11 is a date and D11- C11 are times, ie 4PM and 5PM


Message was edited by: iamzoran

MacBook [MacBook5,1] 2.4 GHz, Mac OS X (10.5.6), Number Of Processors: 1 Total Number Of Cores: 2 L2 Cache: 3

Posted on May 3, 2014 1:41 PM

Reply
23 replies

May 3, 2014 5:44 PM in response to iamzoran

That's an interesting expression. I can't say why you get the error for sure, but I can say that you should be able to write:


=IF(A11>0,D11−C11,"") and get the same result when all your data is properly formatted.


Using SUM with a single cell's value adds nothing, and neither does enclosing the subtraction in parentheses.


Numbers differs a lot from Excel in the Time department. Numbers has a Date/Time value type, which is a precise point in time on a precise date. There is no time of day value. Numbers also has a Duration value type. The result of subtracting two Date/Time values is a Duration value. If you enter only a time of day, the current date is assumed and becomes part of the value.


Jerry

May 4, 2014 1:47 PM in response to Jerrold Green1

Jerrold Green1,


I agree with your words about using Sum with a single cell [have no idea why the "creator" of the file did that]; same for the parentheses enclosing subtraction. Yet cleaning it up as you showed me [=IF(A11>0,D11−C11,"") ] I got the same comment

"You can’t compare a date with a number because their data types are different."


Makes me think that t quinn is on to something with his "think the issue is with the expression ">0". Could it be that >0 is the number referred to and <>"" and ISBLANK are not numbers?!


z


PS: I am so happy that I am able to use Spelling and Grammar Checker with Safari on these posts. I was born and raise in old Yugoslavia and I use the Checker with all my emails etc and its a life saver. hahaha

May 4, 2014 2:31 PM in response to iamzoran

Jerry,


Thank you. IF(LEN(A)<1, "", D-C) worked. So I ask myself, what does all this mean? 3 solutions. I see the simplicity of your formula but I am not sure I am cut out for it, for any of this. i understand it strategically, but when I get on the tactical level I am lost. So what I have learned from this wonderful discussion, I should not be doing this.


I need help, but not to learn, but to have someone who is talented in this area to do it for me. I prototype using spreadsheets but my work product is too crude for use by others. Is this a another question or is it not a question for this type of forum in the first place. If so where do I go to find help?


Appreciate some guidance,


z

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

"You can’t compare a date with a number" in a formula that worked in Excel

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.