473,395 Members | 1,442 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,395 software developers and data experts.

calculating total time using datediff()

hi

i have i table called Description which has details about StartTime , EndTime and ScheduleDate of the various Transaction occuring daily.I want to fetch total time spend on a particular transaction which can occur on any day of week.Eg:

A transaction occured on 5th jan from 2pm to 3pm and
on 6th jan 1pm to 3pm
so total time spent is 1+2= 3 hrs.
Can this be done with a query ? or i hav to do some changes in my code.?



Regards
Jul 30 '07 #1
1 9488
hi

i have i table called Description which has details about StartTime , EndTime and ScheduleDate of the various Transaction occuring daily.I want to fetch total time spend on a particular transaction which can occur on any day of week.Eg:

A transaction occured on 5th jan from 2pm to 3pm and
on 6th jan 1pm to 3pm
so total time spent is 1+2= 3 hrs.
Can this be done with a query ? or i hav to do some changes in my code.?



Regards
This transaction is the same one over and over and you need a running total?

Expand|Select|Wrap|Line Numbers
  1. Select sum(Datediff(hour,StartTime, EndTime))
  2. Where TransactionID = 12345
Or if you want to list the totals for all the transactions.

Expand|Select|Wrap|Line Numbers
  1. Select TransactionID, sum(Datediff(hour,StartTime, EndTime))
  2. Group By TransactionID
These will do it in hours, if you want more precision you use minutes or seconds and then do the math to get your display right.
Aug 1 '07 #2

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

Similar topics

3
by: Phil Sandler | last post by:
All, I have a table with start and end dates/times in it, and would like to be able to calculate the number of hours represented, accounting for overlapping records. Note that I am looking...
1
by: Shaun Thornburgh | last post by:
Hi, I have a table called Bookings which has two important columns; Booking_Start_Time and Booking_End_Time. These columns are both of type DATETIME. Given any day how can I calculate how many...
2
by: hhathome | last post by:
In my report I have a calculated DateDiff Field, I also have a calculated count field. I'm trying to get a total of the DateDiff field and dividing it by the count field and I'm having problems --...
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...
2
by: slinky | last post by:
Anyone know how to calculate the difference between two times displayed in two textboxes? I'm starting out with two textboxes: "txtCallTimeBegins" & "txtCallTimeEnds" this yielded: 6/7/2007...
5
parshupooja
by: parshupooja | last post by:
Hey All, I have following query which gives me 7-8 record select Date, abs((cast((Datediff(mi,MorningIn,MorningOut) + Datediff(mi,AfternoonIn,Afternoonout))/60 as varchar(5))+ '.' + RIGHT('0'...
4
by: Brian | last post by:
I have a 2000/2002 Access db that I use to collect and store my exercisetime using a form to enter. I wanted to see a summary of the total timefor each exercise so I have a subform that does this....
8
by: =?Utf-8?B?QWw=?= | last post by:
I am working in vb2005. how can I calculate business days (not including holidays and weekends) between 2 dates? thanks Al
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.