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 for 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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.