Solved

Adjust time of datetime

Posted on 2012-12-24
2
290 Views
Last Modified: 2012-12-24
Hello all,

I'm running a report at X time every Y hours.  Each time the report runs my vb.net windows form application calculates the next run time and stores that datetime.  I anticipated some drift of time where the report will get progressively later in the day so I kept the original "base time" as a field in the database for this record.  I'm trying to figure out a way to measure if the next run time is more than a minute past the "base time" and if so force the next run time back to the base time.  Aircode:

If nextRunTIme(hh:mm) - BaseTime(hh:mm) > 1 then
       NetRunTime = correct NextRunTime Date but BaseTime Hours:Minutes
End If

In other words:

If NextRunTime (12/24/2012 9:05 PM) - BaseTIme(9/12/2012 9:00 PM) > 1 Then
        NextRunTime = 12/24/2012 9:00 PM
End If

Take the date from NextRunTime but the TIME from BaseTime?

Thanks
0
Comment
Question by:zipnotic
2 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 205 total points
ID: 38719532
Try:

If (nextRunTime.TimeOfDay - baseTime.TimeOfDay).TotalMinutes > 1 Then
    nextRunTime = nextRunTime.Date.Add(baseTime.TimeOfDay)
End If

Open in new window

0
 

Author Closing Comment

by:zipnotic
ID: 38719535
Perfect! You made it easy
Thank You
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now