Hey guys,

I thought getting yesterday's date was now() - 1 but visual studio is giving me error saying '-' is not the right operator. I think now() - 1 was used in VB6. whats the correct way of obtaining yesterday date?

Member Avatar
Unhnd_Exception

Dim Yesterday As Date = DateAndTime.DateAdd(DateInterval.Day, -1, DateAndTime.Now)

thanks but is there a shorter way of coding? shorter is easier to remember..

Remember dateadd and you'll be able to look it up (VS help or google) when you forget it.

got it... i also found the shorter easier way.

Today().AddDays([I]number_of_days(+/-)[/I])

thanks for the help guys