datetime.addminutes

  • Thread starter Thread starter Roger Twomey
  • Start date Start date
R

Roger Twomey

I am doing something wrong here but I cannot see it.

I have the following lines of code:

datNextNotificationDateTime = Me.RunStartTime.AddMinutes(intContactInterval)
WriteLog("NextNotificationDateTime is: " +
datNextNotificationDateTime.ToShortDateString)

So if I run the code line like this:

datNextNotificationDateTime = Me.RunStartTime.AddMinutes(intContactInterval)
(where intContactInterval = 15)

I get datNextNotificationDateTime as the exact same (unchanged, original)
Me.RunStartTime value. It does not appear to be adding 15 minutes.
(the WriteLog function is writing to the EventViewer application log.. this
is a service so I cannot throw an error and see it.)

Any ideas how this could be possible??
 
* "Roger Twomey said:
So if I run the code line like this:

datNextNotificationDateTime = Me.RunStartTime.AddMinutes(intContactInterval)
(where intContactInterval = 15)

I get datNextNotificationDateTime as the exact same (unchanged, original)
Me.RunStartTime value. It does not appear to be adding 15 minutes.
(the WriteLog function is writing to the EventViewer application log.. this
is a service so I cannot throw an error and see it.)

Your code should work except that the number of minutes added to the
'DateTime' should be a 'Double' instead of an 'Integer'.
 
Hi Roger,

In the code you presented RunStartTime is never changed so this statement:

datNextNotificationDateTime = Me.RunStartTime.AddMinutes(intContactInterval)

... always sets datNextNoficiationDateTime to the result of the value of
RunStartTime + 15 minutes. (The statement assigns the result of
Me.RunStartTime.AddMinutes(intContactInterval) to
datNextNotificationDateTime, it does not change the value of RunStartTime)

If you wish to leave RunStartTime's initial value alone, AddMinutes to
datNextNotificationDateTime instead:
datNextNotificationDateTime =
Me.datNextNotificationDateTime.AddMinutes(intContactInterval)
 
Back
Top