473,785 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

diff between 2 DATETIMEs, SUMmed & GROUPed BY project

SELECT id,name, prj,SUM(TIMEDIF F(end_time,star t_time)) AS elapsed
FROM work
group by name,prj;

The problem is, I need elapsed in a datetime format, and SUM truncates to
integer hours.

Is there no way to do this?
I just want the group sums as hours, minutes, dats, months, years.
Mar 14 '06 #1
2 1472

"Jim Michaels" <NO************ ***@yahoo.com> wrote in message
news:Zq******** ************@co mcast.com...
SELECT id,name, prj,SUM(TIMEDIF F(end_time,star t_time)) AS elapsed
FROM work
group by name,prj;

The problem is, I need elapsed in a datetime format, and SUM truncates to
integer hours.

Is there no way to do this?
I just want the group sums as hours, minutes, dats, months, years.


CREATE VIEW workhourstot AS
SELECT id,name, prj,sum(hour(ti mediff(end_time ,start_time))) AS hour,
sum(minute(time diff(end_time,s tart_time))) AS minute
FROM work
GROUP BY name,prj;

This worked for me I guess, but one of the minutes ended up as 70. I think
it's because of the grouped sum. ugh. I need a solution.

datediff is out of the question.
Mar 15 '06 #2

"Jim Michaels" <NO************ ***@yahoo.com> wrote in message
news:TO******** ************@co mcast.com...

"Jim Michaels" <NO************ ***@yahoo.com> wrote in message
news:Zq******** ************@co mcast.com...
SELECT id,name, prj,SUM(TIMEDIF F(end_time,star t_time)) AS elapsed
FROM work
group by name,prj;

The problem is, I need elapsed in a datetime format, and SUM truncates to
integer hours.

Is there no way to do this?
I just want the group sums as hours, minutes, dats, months, years.


CREATE VIEW workhourstot AS
SELECT id,name, prj,sum(hour(ti mediff(end_time ,start_time))) AS hour,
sum(minute(time diff(end_time,s tart_time))) AS minute
FROM work
GROUP BY name,prj;

This worked for me I guess, but one of the minutes ended up as 70. I
think it's because of the grouped sum. ugh. I need a solution.

datediff is out of the question.


figured it out.
CREATE VIEW workhourstot AS
SELECT id,name, prj,(SUM(MINUTE (TIMEDIFF(end_t ime,start_time) )) DIV
60)+SUM(HOUR(TI MEDIFF(end_time ,start_time))) AS hour,
MOD(SUM(MINUTE( timediff(end_ti me,start_time)) ),60) AS minute
FROM work
GROUP BY name,prj;
Mar 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
983
by: Michael Pfeifer | last post by:
Hi all, I need to convert datetimes from any timezone to UTC and back considering daylight saving. It is not enough, to just add or subtract the timezone offset. Also, I can not use c functions and structures like localtime and time_h, since they only can handle datetimes "younger" than 01/01/1970. I need to handle birthday dates also. I tried to integrate Boost libraries (see www.boost.org), but I was not able to get them running...
1
2510
by: Megan | last post by:
quick summary: i'm having problems trying to group fields in a report in order to calculate percentages. to calculate percentages, i'm comparing the results from my grouped fields to the totals. first, let me say that this is a really long post. i wasn't sure how much information/ background to provide, so i thought more was better than less. i tried to delineate certain areas so that it would be easy to peruse my posting and find...
9
6520
by: Ching-Lung | last post by:
Hi all, I try to create a tool to check the delta (diff) of 2 binaries and create the delta binary. I use binary formatter (serialization) to create the delta binary. It works fine but the delta binary is pretty huge in size. I have 1 byte file and 2 bytes file, the delta should be 1 byte but somehow it turns out to be 249 bytes using binary formatter. I guess serialization has some other things added to the delta file.
4
4957
by: Andreas Kasparek | last post by:
Hola! I'm preparing my master thesis about a XML Merge Tool implementation and was wondering if there is any open standard for XML diff regarding topics like: - is a diff result computed on the ordered or unordered xml node tree of the compared documents? - what identifiers/criteria should be used by default to match elements of the same type in different documents? - should a diff tool consider move operations or only insert/delete
3
1819
by: Pieter Coucke | last post by:
Hi, For some reason, somewhere in my application 1 hour is added to my dates, depending in which time zone the application is run... Because I don't have a clue where this happens, I posted this to the three relevant newsgroups (vb/ado, sql and xml): my aplogize for this. I'm doing a Synchronisation between two SQL Servers (2000): All the Data is read into a DataSet, and exported to an XML-file: SQL Server -> DataSet (VB.NET 2003) ->...
8
1577
by: Dave | last post by:
I have a set of developers who have gone off and implemented an interface for nearly all classes in a project\solution, now some of these classes will need interfaces as they implement the provider design pattern and other classes are exposed to the outside world, but the majority are internal classes and therefore IMO they don't require an interface. I can find plenty of articles on how to implement interfaces but I can't find any...
6
5153
by: ppravin88 | last post by:
hi guys 'n' gals .. could anyone tell me the difference between getch(); and getche(); and when and where should we use this function... and also wat is the diff between return(); & return(0); & return(1);..........
4
1783
by: Shug | last post by:
Hi, We're reformatting a lot of our project code using the excellent uncrustify beautifier. However, to gain confidence that it really is only changing whitespace (forget { } issues for just now), we were hoping to do a diff - a textual comparison of the files, ignoring whitespace. However, most diffs we've tried can't handle multi-line whitespace, so
7
3687
by: magix | last post by:
Dear Guru, If I want to compare time, what is the best approach to go ? Any good example ? DateDiff ( ) ? Pseudocode ======== submitdate = rs.fields("submissiondate") -submissiondate is a date field in a table.
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10153
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9952
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.