Hi

i try to sum two column in Sql, but don't get it....

this way is not working....

sum(SUM(DISTINCTDATEDIFF(mi, dbo.WORK_HISTORY.WORK_BEGIN_TIME, dbo.WORK_HISTORY.WORK_END_TIME))+
sum(distinct datediff(mi, dbo.work_history.work_begin_date, dbo.work_history.work_end_date))) ,

and with that is not working to

SUM(DISTINCTDATEDIFF(mi, dbo.WORK_HISTORY.WORK_BEGIN_TIME, dbo.WORK_HISTORY.WORK_END_TIME)) as A ,
sum(distinct datediff(mi, dbo.work_history.work_begin_date, dbo.work_history.work_end_date)) as B, sum(A+B) as Result

can someone help me please... Thanks

ok, let's start from scratch. give me a brief description of what exactly you are trying to accomplish. including field types and names

something like
I have three columns: workerid, begin_time and end_time
I want to know the total time that a worker with workerid X worked during june
Or I want to know how many how many different workers worked on june 15th.
etc

ok, let's start from scratch. give me a brief description of what exactly you are trying to accomplish. including field types and names

something like
I have three columns: workerid, begin_time and end_time
I want to know the total time that a worker with workerid X worked during june
Or I want to know how many how many different workers worked on june 15th.
etc

hi,

Ok I try to descripe my problem.

I have a User which work for a someone and he have to raport the time he worked. The bad thing in this database is, that the time and the date is saved in a different field.

So he worked on the 06/19/2006 from 10:00 am until 06/21/2006 07:00 am. At least I want to find out, how many hours he worked.

in the database it looks like this:

User : xxxx
work_begin_time 2006-06-23 10:00:00
work_begin_date 2006-06-19 02:00:00
work_end_time 2006-06-23 07:00:00
work_end_date 2006-06-21 02:00:00

Now I thought, that I could count the differenc between the time and the date and count this two results together.

can you help me ?

thanks

and I suppose changing the database is out of the question?

also, do you need minutes?

Yes it's definitv out of question. :-) yes I need minutes...

are they stored in the time column, or their own column

How you mean that ? In the db it's datetime format

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.