.AddHours doesn't work!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Nguyen

    #1

    .AddHours doesn't work!

    What Am I missing?

    Please help!!!

    Thanks

    Bill

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

    mEffDateTime.Ad dHours(-5)

    MsgBox(mEffDate Time.ToString)






  • Joergen Bech

    #2
    Re: .AddHours doesn't work!

    On Wed, 20 Jun 2007 11:31:27 -0700, "Bill Nguyen"
    <billn_nospam_p lease@jaco.comw rote:
    >dim mEffDateTime as DateTime
    >mEffDateTime = Now
    >
    >mEffDateTime.A ddHours(-5)
    >
    >MsgBox(mEffDat eTime.ToString)
    AddHours is a function - not a method.

    Use

    mEffDateTime = mEffDateTime.Ad dHours(-5)

    Regards,

    Joergen Bech



    Comment

    • Rory Becker

      #3
      Re: .AddHours doesn't work!

      What Am I missing?
      >
      Please help!!!
      >
      Thanks
      >
      Bill
      >
      ---------
      dim mEffDateTime as DateTime
      mEffDateTime = Now
      mEffDateTime.Ad dHours(-5)
      >
      MsgBox(mEffDate Time.ToString)
      >

      mEffDateTime = mEffDateTime.Ad dHours(-5)

      --
      Rory


      Comment

      • =?Utf-8?B?TW9kZWxCdWlsZGVy?=

        #4
        RE: .AddHours doesn't work!

        AddHours does not change the object, but is a function that returns a new
        object. Try:

        MsgBox (mEffDateTime.A ddHours(-5).ToString)

        "Bill Nguyen" wrote:
        What Am I missing?
        >
        Please help!!!
        >
        Thanks
        >
        Bill
        >
        ---------
        dim mEffDateTime as DateTime
        mEffDateTime = Now
        >
        mEffDateTime.Ad dHours(-5)
        >
        MsgBox(mEffDate Time.ToString)
        >
        >
        >
        >
        >
        >
        >

        Comment

        • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

          #5
          RE: .AddHours doesn't work!

          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


          "Bill Nguyen" wrote:
          What Am I missing?
          >
          Please help!!!
          >
          Thanks
          >
          Bill
          >
          ---------
          dim mEffDateTime as DateTime
          mEffDateTime = Now
          >
          mEffDateTime.Ad dHours(-5)
          >
          MsgBox(mEffDate Time.ToString)
          >
          >
          >
          >
          >
          >
          >

          Comment

          • Bill Nguyen

            #6
            Re: .AddHours doesn't work!

            Oh boy!

            Thank you all for pointing out my bad!

            Bill

            "Joergen Bech @ post1.tele.dk>" <jbech<NOSPAMNO SPAMwrote in message
            news:55ui731kib 4oimv2hkgtilds1 17dbd2r2f@4ax.c om...
            On Wed, 20 Jun 2007 11:31:27 -0700, "Bill Nguyen"
            <billn_nospam_p lease@jaco.comw rote:
            >
            >>dim mEffDateTime as DateTime
            >>mEffDateTim e = Now
            >>
            >>mEffDateTime. AddHours(-5)
            >>
            >>MsgBox(mEffDa teTime.ToString )
            >
            AddHours is a function - not a method.
            >
            Use
            >
            mEffDateTime = mEffDateTime.Ad dHours(-5)
            >
            Regards,
            >
            Joergen Bech
            >
            >
            >

            Comment

            • Michael D. Ober

              #7
              Re: .AddHours doesn't work!

              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.

              "Bill Nguyen" <billn_nospam_p lease@jaco.comw rote in message
              news:O1vT4k2sHH A.3504@TK2MSFTN GP05.phx.gbl...
              What Am I missing?
              >
              Please help!!!
              >
              Thanks
              >
              Bill
              >
              ---------
              dim mEffDateTime as DateTime
              mEffDateTime = Now
              >
              mEffDateTime.Ad dHours(-5)
              >
              MsgBox(mEffDate Time.ToString)
              >
              >
              >
              >
              >
              >
              >


              Comment

              Working...