Solved

GET TOTAL TIME

Posted on 2004-04-16
5
178 Views
Last Modified: 2010-05-02
hey guys i juss wanna ask ur help getting the total time of my project... in my table, i have datetime_in, datetime_out, total_time...

e.g
datetime_in= 04/17/04 10:00:00 AM
datetime_out=04/23/04 10:00:00 PM
total_time=?

thanks
0
Comment
Question by:zack_online
  • 2
  • 2
5 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 10848056
Hi zack_online,

Total_Time = DateTime_Out - DateTime_In
(all three should be declared as Date type)
Cheers!
0
 

Author Comment

by:zack_online
ID: 10848241
tnx 4 d reply... how do i get the result in vb? can u gimme a simple sample of this...

tnx again
0
 
LVL 1

Expert Comment

by:MortimerCat
ID: 10848397
Dim datetime_in As Date
Dim datetime_out As Date
Dim total_time As Long

datetime_in = #4/17/2004 10:00:00 AM#
datetime_out = #4/23/2004 10:00:00 PM#

total_time = DateDiff("d", datetime_in, datetime_out)

MsgBox total_time

The first parameter "d" indicates how accurate you want the answer.  "d" for days "h" for hours See Help for other settings.

The program above shows 6 ie 6 days.

"h" gives 156 hours.  This will need further manipulation, ie dividing by 24, to get Days &  Hours

See also Datepart & Dateadd
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 200 total points
ID: 10848416
I'm having trouble understanding you, but I hope this is what you need. It also demonstrates the DateDiff function which shows the elapsed time in particular units, seconds in this case.

Private Sub Command1_Click()
    Dim DateTime_In As Date
    Dim DateTime_Out As Date
    Dim Total_Time As Date
   
    DateTime_In = Now()
    MsgBox "Hello Zack"
   
    DateTime_Out = Now()
    Total_Time = DateTime_Out - DateTime_In
    MsgBox "Time to respond was " & Total_Time & " or " & DateDiff("s", DateTime_In, DateTime_Out) & " seconds"
End Sub


0
 

Author Comment

by:zack_online
ID: 10856164
tnx for answering my Q.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Saving history changes to sub form 4 42
vb6 connector to mongodb 2 81
How to make an ADE file by code? 11 83
how to Classify of email (pdf attachments) 7 35
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

776 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