0

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?

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by bluehangook629
0

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

0

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

0

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

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

thanks for the help guys

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.