If statement using date

lfcreds11

New Member
Joined
Oct 12, 2009
Messages
29
I am trying to write a formula to show if cell A2 is blank then show 0 in B2, if it has a date listed then show the amount of days difference between today's date and the date listed in column A.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Or more simply:
Excel Formula:
=IF(A2="",0,A2-TODAY())

You can do this because Excel actually stores dates as numbers, specifically the number of days since 1/0/1900.
So since Dates are really stored as "days", you can simply subtract two dates to get the number of days between them.
 
Upvote 0
Solution
Or more simply:
Excel Formula:
=IF(A2="",0,A2-TODAY())

You can do this because Excel actually stores dates as numbers, specifically the number of days since 1/0/1900.
So since Dates are really stored as "days", you can simply subtract two dates to get the number of days between them.
Thank you! This worked perfect too! Thank you for the explanation on how it works.
 
Upvote 0
You are welcome.

Glad we could help!
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,236
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top