0

Cells B2 and B3 each have a date entered in them. I want to compare the two dates and display the earlier date in cell C2. Or, stated another way:

if B2 < B3, display B2 in cell C2
if B3 < B2, display B3 in cell C2

I do something like this with Acrobat's JavaScript but am lost with Google Sheets.

var date1 = this.getField("txt_date.0").value;
var date2 = this.getField("txt_date.1").value;

if(date1 < date2)
event.value = date1;
if(date2 < date1)
event.value = date2;

2 Answers 2

2

I got some assistance with this. Either of the following will work. Posting in case it helps someone else.

=IF(B2<B3,B2,B3)

or

=MIN(B2:B3)
1
  • 1
    Posting in case it helps someone else. Always a good idea - paying it forward.
    – Tedinoz
    Oct 24, 2021 at 23:22
0

I still can't post comments because I haven't reached 50 reputation points. However, I cannot fail to recommend only the first formula and to reject the second, at least for how it was written ... the second can give an incorrect result if the two cells (B2 and B3) are emptied and C2 has been formatted as date

2
  • Use =iferror( 1 / min(B2:B3) ^ -1 ). Oct 25, 2021 at 9:36
  • yes, that solve the above problem
    – Daniele
    Oct 25, 2021 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.