Search code examples
excelvbaformatdateadd

vba dateadd method drives me crazy


enter image description here

It is results from the vba Direct Run window. There is no operation in the screenshot above. Is my Excel crazy? Somebody please convince me. Thank you.


Solution

  • It is not DateAdd to blame, it is yourself not knowing what Now and Format does.

    Now contains a time part which you round up or down using Format and "#" (or "0").

    So, use Date:

    DateBeforeYesterday = DateAdd("d", -2, Date)