OpenOffice boolean if function
Someone asked me how they would use boolean statements in OpenOffice's Spreadsheet application, Calc.
In my previous example showing how to calculate the number of days between 2 dates I set cells A1 and B1 to be dates and set C1 to be a formula that used the "DAYS" function to calculate the number of days between the two dates.
If you wanted to only output the calculation if A1 and B1 were greater than zero and output 0 otherwise you could use the "IF" and "AND" functions as follows:
The "IF" function takes three parameters:
1st - a boolean test, in this case "AND(A1>0;B1>0)"
2nd - a value to output if the test evaluates to TRUE, in this case "DAYS(A1;B1)"
3rd - a value to output if the test evaluates to FALSE, in this case "0"
Spreadsheets are really quite versatile. It's surprising just how much they can do.
If you have any comments please let me know and if you have any other questions which you'd like me to answer for free please send them to Ben Dash at email@example.com