Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Formula to check if dates are in chronological order?

This can be accomplished in Excel via SUMPRODUCT:

https://exceljet.net/formulas/all-dates-in-chronological-order


Essentially, to my understanding, Excel can check two ranges (ex: A2:A9 &A3:A10) and compare the Nth value in each corresponding range. So for example, it would first compare A2 to A3 (one could set up a comparison to check if A3 > A2, for instance). Then compare A3 to A4, and so on...

Is there a similar way to do this in Numbers? I can't seem to replicate this (I know, I know... Excel is different than Numbers...)


I have a column of dates that I want to check to see if they are in chronological order:


If it is not possible to do with dates, is it possible to do with number values?

Please note that I want one formula that will check to make sure the values in the column are in chronological order, I know how to accomplish this using formulas in each individual row- where a formula in row 3 checks if the date in row 3 is before/after the date in row 2, then a formula in row 4 compares the date in row 4 to the date in row 3, etc.- but that would mean every row has a formula, which I'm trying to avoid. I'd like to know if this is possible using a single formula, as shown in the excel link above.

Posted on Jul 7, 2023 12:31 AM

Reply
Question marked as Best reply

Posted on May 1, 2024 7:49 AM

I can't think of a formula to handle every case. A simple formula is

B1 formula = IF(A1>A2,"Out of Order","")

Fill down

The last row of the table will be an error due to an invalid reference.


As you fix ones that are marked, others might get marked. For example, if your table had 22.03.24 and 23.03.24 consecutively in the table, the first would not be marked but the second would. After fixing the second, the first would get marked.


The problem with all formulas is what I was getting at in my earlier post. If there is a block of dates out of order, which ones do you mark out of order.


Here is one that marks a date out of order if there is a smaller date below it in the table (of 1000 rows):

=IF(COUNTIF(A1:A$1000,"<"&A1)>0,"Out of Order","")


Here is one that marks a date out of order if there is a larger date above it in the table. It will not consider 22.03.24 to be out of order in your table but both 19.02.21 dates will be.

=IF(COUNTIF(A$1:A1,">"&A1)>0,"Out of Order","")



8 replies
Question marked as Best reply

May 1, 2024 7:49 AM in response to TaniaCampher

I can't think of a formula to handle every case. A simple formula is

B1 formula = IF(A1>A2,"Out of Order","")

Fill down

The last row of the table will be an error due to an invalid reference.


As you fix ones that are marked, others might get marked. For example, if your table had 22.03.24 and 23.03.24 consecutively in the table, the first would not be marked but the second would. After fixing the second, the first would get marked.


The problem with all formulas is what I was getting at in my earlier post. If there is a block of dates out of order, which ones do you mark out of order.


Here is one that marks a date out of order if there is a smaller date below it in the table (of 1000 rows):

=IF(COUNTIF(A1:A$1000,"<"&A1)>0,"Out of Order","")


Here is one that marks a date out of order if there is a larger date above it in the table. It will not consider 22.03.24 to be out of order in your table but both 19.02.21 dates will be.

=IF(COUNTIF(A$1:A1,">"&A1)>0,"Out of Order","")



May 1, 2024 6:09 AM in response to TaniaCampher

If you have these dates in this order,

1/1/24

1/4/24

1/5/24

1/2/24

1/3/24


Which ones are the ones not in order. Choices are

  1. All dates below 1/1 are out of order (because all of them will move around if sorted)
  2. 1/4 and 1/5 are out of order (because there are earlier dates lower in the table)
  3. 1/2 and 1/3 are out of order (because there are later dates higher in the table)


Also, will the dates all be consecutive or will there be gaps?




Jul 7, 2023 8:40 AM in response to PuddleOfFat

The Excel example uses an Excel "array" formula that basically does an entire column of comparisons all within the one cell. Numbers does not have that capability.


If your columns are short and of fixed length and all cells have dates in them, you could do all the comparisons within one cell

=AND(A2>A3,A3>A4,...etc)

Result will be TRUE if it is in order, FALSE if not.

The formula will work if there are empty cells at the bottom of the column but it will have a blue warning triangle.


One advantage of doing the comparisons in an adjacent column vs in a single cell is you can quickly see where the problems are.

Jul 7, 2023 10:26 AM in response to PuddleOfFat

I am not sure a single formula that does a column of comparisons within one cell is any faster than a column of separate formulas. It might be. I recommend using Excel if speed is an issue. It is orders of magnitude faster than Numbers. And I do mean orders of magnitude; I am not exaggerating. For smaller spreadsheets the difference is not noticeable but for huge ones with lots of formulas, a spreadsheet that Excel can recalculate in a split second will take Numbers several minutes or even longer. If your spreadsheet is too slow in Numbers, it might not be the right app to be using.

May 1, 2024 5:40 AM in response to Badunit

I have an excel document with up to 1000 rows all containing data over various columns. All I need is a formula to run from A1 to A1000 and show / highlight dates that are out of chronological order. I want to check that row and decide if row should move or if date should be changed. No sorting options please.. I need to be able to only see where dates are not in chronoligal order. I can add columns if needed and delete afterwards when done. Hope there is a solution coz cheching 1000 rows is time consuming and still have errors.

Formula to check if dates are in chronological order?

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