Using dates in a logic formula explanation please

Dynamo Nath

Board Regular
Joined
Aug 5, 2009
Messages
142
This is probably straight forward and I'll kick myself when it's explained.

I was using a formula to compare dates:

=IF(AND(J5<"1/6/11"+0,K5>"15/6/11"+0),"true","false")

and I couldn't get it to work properly so I hunted around on the net and found the above. For the life of me I can't figure out why the +0 makes it work!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
By adding 0 it is converted in the number, here date is converted in serial number
 
Upvote 0
Dates are stored as numbers by excel as a number of days since a given date.

"11/05/2011" is a string. Adding a value (in this case zero, so there's no overall change) forces Excel to turn that string into a number, at which point Excel recognises it as a date and enacts the rest of the formula acordingly.

it's the equivalent of

=DATEVALUE("11/05/2011")

which would work just as well (but is more long winded)
 
Upvote 0
Thanks for the replies. I wondered if it was something to do with converting it between strings and stuff but wasn't entirely sure. Nice to have it confirmed :)
 
Upvote 0

Forum statistics

Threads
1,224,526
Messages
6,179,322
Members
452,906
Latest member
Belthazar

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