Subtracting from a date in VBA? Subtracting from a date in VBA? vba vba

Subtracting from a date in VBA?


I suggest looking at the DateAdd function for VBA

http://www.techonthenet.com/excel/formulas/dateadd.php

http://office.microsoft.com/en-us/access-help/dateadd-function-HA001228810.aspx

You could do the following:

Format(DateAdd("d", -4, CDate(Me.datalivrare.Value)), "dd.mm.yyyy")


First cast to Date, then subtract days, then format appropriately:

Format(DateAdd("d", -4, CDate(Me.datalivrare.Value)), "dd.mm.yyyy")


the best to add and substract from dates on vba is dateadd() (with negative number for substractions)also, in your example code there's a missing y on the format string (it accepts 1, 2 or 4 y, only)