Sumifs not returning correct value for a date range?

Hi! I have recently learned (sort of) how to use this function. I am using it to calculate the flying hours I have logged during certain periods, e.g: january 2011, or specific dates ranges.


The formula will work correctly if I input cells B9 and B11 as the same value (the same date), and the value returned in cell B6 is correct...


however when I put in different values in cells B9 and B11 (a date range), the value returned in B6 is incorrect!

I am expecting a value of "1.9" in one example, however the value returned is "2.6"

~And yes, I have rechecked the values so it's not just my bad maths!


I am thinking my date formats are the problem maybe?


the sheet named "Logbook Entries" has the same format as cells B9 & B11 as per the screenshot. These "dates" are not actually in the date format I believe as they appear as "Text" as per the second screeenshot. I should have thought to input them as proper dates back when I first started this spreadsheet in 2011..


I can't work out how to convert them now though if this is the problem?

(there are nearly 1000 entries so would prefer not to manually re-enter them again as dates!)


Any help would be greatly appreciated!


Thanks

User uploaded fileUser uploaded file

MacBook Air, OS X Mavericks (10.9.2)

Posted on Apr 14, 2014 3:36 PM

Reply
19 replies

Apr 15, 2014 9:12 PM in response to michaellusty

Hi Michael,


Could you experiment a little and advise which formats Numbers will convert to date & time for you?


For example, if you type a single quote followed by Mar 07, 2011 that should be text in the cell. Can you then take that cell and format it as Date & Time?


How about a single quote followed by 2011-03-07? Will that convert?


Or does some other format convert?


Once we know one or two formats that Numbers will convert for you then it shouldn't be too hard to suggest a relatively short AppleScript to convert your existing "date" strings into one of those formats, which you can then have Numbers format as Date & Time. Running an AppleScript can be as simple as copying and pasting a script from a post here into AppleScript Editor, then clicking the green triangle 'Run' button.


If you find Numbers won't convert any format then it wouldn't hurt to try uninstalling it and reinstalling. To uninstall go to LaunchPad, hold down the option key until the icons quiver, then click the x by the Numbers icon with the four columns. Then go to the Mac App Store and redownload.


SG

Apr 15, 2014 10:05 PM in response to michaellusty

Ok, if your "dates" are all uniformally in the format Mar-07-2011, then the following script will convert them to Mar 07, 2011, which you can then format in Numbers as Date & Time. This assumes they are all uniform. If they vary then a more elaborate script will become necessary.


As this overwrites existing content, I suggest trying this on a copy of your original document.


  1. Copy the script and paste it into AppleScript Editor.
  2. Select the cells with the "dates" in format Mar-07-2011.
  3. Click the green triangle 'Run' button.
  4. Format the cells as Date & Time.


SG



--converts string from Mar-07-2011 format to Mar 07, 2011 format

--select cells with Mar-07-2011 format, run script, format cells as Date & Time

try

tell application "Numbers" to tell front document to tell active sheet to tell (first table whose class of selection range is range)

tell selection range to repeat with aCell in cells

set aValue to value of aCell

set myDay to text 5 thru 6 of aValue

set myMonth to text 1 thru 3 of aValue

set myYear to text 8 thru 11 of aValue

set value of aCell to myMonth & " " & myDay & ", " & myYear

end repeat

end tell

on error

display dialog "Select some cells and try again" buttons "OK"

end try

--end of script

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.

Sumifs not returning correct value for a date range?

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