PC Review


Reply
Thread Tools Rate Thread

datetime.addminutes

 
 
Roger Twomey
Guest
Posts: n/a
 
      12th Apr 2004
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??


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      12th Apr 2004
* "Roger Twomey" <(E-Mail Removed)> scripsit:
> 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'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
Mike McIntyre
Guest
Posts: n/a
 
      12th Apr 2004
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)


--
Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"Roger Twomey" <(E-Mail Removed)> wrote in message
news:uzN1R$(E-Mail Removed)...
> 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??
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Millisecond values missing when inserting datetime into datetime column of sql Server Manikandan Microsoft C# .NET 4 18th Jul 2007 08:59 PM
How can I save a DateTime from my C# program into a SQL Server (datetime) database column. Steve Kershaw Microsoft ASP .NET 5 29th Aug 2006 03:10 AM
System.DateTime doesn't convert to SqlDbType.DateTime Narshe Microsoft C# .NET 3 2nd Nov 2005 05:42 PM
DateTime AddMinutes Format Issue Fritz Switzer Microsoft C# .NET 15 20th Jul 2004 03:32 AM
converting Unix datetime count to .Net DateTime object Mark Worrall Microsoft Dot NET Framework 2 13th Feb 2004 05:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:55 AM.