Solved

Adjust time of datetime

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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 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