# Thread: Calculate work order aging with IF statement for blanks. Thanks: 0 Likes: 0

1. ## Calculate work order aging with IF statement for blanks.

Hello.

I need to calculate the age of a work order using the start date (a2) and end date (b2). The “open” work orders will have a blank end date.

I want to write a formula that will use today’s date as the end date if the end date cell is blank. I’m assuming I use an IF statement, but not sure how to write it.

2. ## Re: Calculate work order aging with IF statement for blanks.

=if(b2="",today()-a2,b2-a2)

3. ## Re: Calculate work order aging with IF statement for blanks.

Originally Posted by JoeMo
=if(b2="",today()-a2,b2-a2)
Thank you!!’

4. ## Re: Calculate work order aging with IF statement for blanks.

another way

A
B
C
D
1
StartDate EndDate Age
2
10/07/2019
20/07/2019
10
=IFERROR(CHOOSE(MATCH(--ISBLANK(B2),{0,1},0),DATEDIF(A2,B2,"d"),DATEDIF(A2,TODAY(),"d")),"")
3
20/07/2019
30/07/2019
10
4
30/07/2019
10/08/2019
11
5
10/08/2019
5
6
20/08/2019
7
30/08/2019