Solved

Adjust time of datetime

Posted on 2012-12-24
2
296 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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