.AddHours doesn't work!

  • Thread starter Thread starter Bill Nguyen
  • Start date Start date
B

Bill Nguyen

What Am I missing?

Please help!!!

Thanks

Bill

---------
dim mEffDateTime as DateTime
mEffDateTime = Now

mEffDateTime.AddHours(-5)

MsgBox(mEffDateTime.ToString)
 
dim mEffDateTime as DateTime
mEffDateTime = Now

mEffDateTime.AddHours(-5)

MsgBox(mEffDateTime.ToString)

AddHours is a function - not a method.

Use

mEffDateTime = mEffDateTime.AddHours(-5)

Regards,

Joergen Bech
 
What Am I missing?
Please help!!!

Thanks

Bill

---------
dim mEffDateTime as DateTime
mEffDateTime = Now
mEffDateTime.AddHours(-5)

MsgBox(mEffDateTime.ToString)


mEffDateTime = mEffDateTime.AddHours(-5)
 
AddHours does not change the object, but is a function that returns a new
object. Try:

MsgBox (mEffDateTime.AddHours(-5).ToString)
 
Bill,

You have missed the part of the documentation for AddHours that explains
that it RETURNS a DateTime that is the specified number of hours away from
the specified DateTime.

Kerry Moorman
 
The System.DateTime class is immutable. This means that all methods of
DateTime are functions that return a new value and the original value is
left unchanged.

Mike Ober.
 
Back
Top