[Android CBL 2.0]
Suppose I have a document property “InStock”, and another “CostPrice”.
I have found that to create a new column in the query, “TotalCost”, simply create two property expressions and multiply them:
Expression inStockExpression = Expression.property(“InStock”);
Expression costPriceExpression = Expression.property(“CostPrice”);
Then simply return new Expression from inStockExpression.multiply(costPriceExpression)
This works nice for all arithmetic operations between the two existing NUMBER properties.
Ok. So what’s the question?
If property #1 is a date, like “DatePurchased” and property #2 is another date, “DateSold”, and I want a new derived column, an Integer, for the number of days between “DateSold” and “DatePurchased”, how do I do that? (I want a number based on computing two dates.)
1B. If I simply want to add an Integer, say 30 days, to “DatePurchased”, and the new derived column should be a DATE, how do I do that?
How do I manually evaluate property expressions? Like the inStockExpression above. I am looking for something like Expression.intValue(Expression). Having the answer to this will allow me accomplish date manipulations manually, to solve question 1 and 1b, etc.
This has stumped me quite a bit, and I feel like the answer is glaring me in the face and am too dumb to see it.
Thank you much!