473,413 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Calculating time passed in a range

Hi all,

I've got a project where I need to calculate the time passed between an acceptable range.
For example

E-mail was received at 19:00 and a response was sent at 09:00
The acceptable range is 8am to 6pm so in the scenario it shoudl return 60 mins.

Another example is if the email was received at 16:00 reply was sent on 10:00 am next day it should return 240.

Any thought how to acehive this.

Ive saved the data in variable as timein and timeout
Oct 6 '12 #1
1 1346
!NoItAll
297 100+
look at the date class and methods. You need to incorporate the entire date so it takes into account when items cross midnight.
Here's an example of comparing now with another date 3 hours into the future. You can put in the appropriate times that you want.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim Timein As Date = Now
  3. Dim TimeOut As Date = Timein.AddHours(CDbl(3))
  4.  
  5. Dim Diff As Long = TimeOut.Subtract(Timein).TotalHours
  6.  
  7. MsgBox(Diff.ToString)
  8.  
  9.  
Oct 11 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: T-Narg | last post by:
I would like to produce the following output based on my XML file: My Album (2005) Elapsed Time (hh:mm:ss): 00:07:00 Song 1: title1 Length (hh:mm:ss): 00:02:30 Song 2: title2 Length...
4
by: Adam Balgach | last post by:
Greets all, i am in the process of writing a simple client/server file upload program that sends data via UDP packets. I have the process of opening.sending, recieving & writing all working...
4
by: luscus | last post by:
I am trying to device a formula so that when i check of a yes/no box (done) it will automatically add the time in a field called "End Time" and at the same time stamp the amount of minutes...
3
by: luscus | last post by:
Thanks for all the responses on my first question. Unfortunately the answers I was given were too complicated for my small brain , and neophite condition to understand. So if you could talk down to...
25
by: Blaize | last post by:
Hi, I'm having an issue trying to calculate time. Its okay if the value does not exceed 24 hours otherwise I get a date and hours listed. For example, I have a loop which looks through a table...
6
by: Adam1331 | last post by:
I am currently setting up a database for work that will operate as a timesheet. I have set up multiple tables, queries, forms and reports to help this process run smoothly. The issue that has...
3
by: mfaisalwarraich | last post by:
Hi everybody. I have some problem while calculating time. i have employees who are working on hourly basis. i want to calculate the time. for example if an employee start working at 11:00pm...
4
by: Missionary2008 | last post by:
Thank you in advance for your help. I'm trying to calculate the Total Time in hours and minutes to complete a job. The way we are calculating it is by taking the Fee paid and dividing that by a...
3
Claus Mygind
by: Claus Mygind | last post by:
My date calculation do not seem to work out. I have a list box with a character string value of dates ie: 03/28/2009. I want to create a date range for the week. So I would like to get the...
3
by: Miguel Valenzue | last post by:
I want to count the number of items that occur within a range of time throughout different days. My original data comes from a machine that logs the time a car passes a point in a road over...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.