DateValue(Now + 2) fails in a macro because "Now + 2" returns as a double rather than as a date. The same is true for "Now - 2".
This bug was introduced by Noel Power 06-Dec-2010 with commit
1421b098ae19a10acb4836fa3752188cf7c52eb2 (thank you Regina for looking that up for me, I do not know how to check that)
The problem is found in file:
There is a switch statement around line 1312. Following the switch statement, there used to be the following code:
// #45465 Date braucht bei + eine Spezial-Behandlung
if( eOp == SbxPLUS && (GetType() == SbxDATE || rOp.GetType() == SbxDATE ) )
aL.eType = SbxDATE;
I am not an expert on these things, but, it looks like the checks to see if either operand is a date, and, if so, sets the type to be date. This was done after PLUS, EXP, MUL, DIV, MINUS, and NEG.
That line was removed and added after PLUS as a comment, so, I assume that NOEL was unsure why it was required. Still waiting on input from NOEL.
I speculate that this was done as part of clean-up because this check was performed every time. Off hand, I can not think of why you might do this for anything other than PLUS or MINUS, but, this breaks existing macros. so I would call this a regression bug.
I reproduced this on a Fedora Linux system (64-bit), but, I expect this to affect all platforms.
reassign to me, also mark as fixed on master