?
Solved

Adjust time of datetime

Posted on 2012-12-24
2
Medium Priority
?
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 820 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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 …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 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