Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to sum time with counting??

Author  Topic 

sagitarius2k
Starting Member

5 Posts

Posted - 2012-01-16 : 08:15:42
hello, how to make counting time with 24 hour format??

here is big picture

[URL=http://imageshack.us/photo/my-images/196/333333333333333333333.png/][/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]

Red word = branch 1
blue word = branch 2

So, branch 1 shipping stuff to branch 2, and this database trying to measure how much time to travel from branch 1 to branch 2.

I am trying to make datawarehousing from this data.

Thanks in advanced :)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-16 : 10:12:57
sorry how do you relate between them? I see even PK value is different for them

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sagitarius2k
Starting Member

5 Posts

Posted - 2012-01-16 : 11:14:13
quote:
Originally posted by visakh16

sorry how do you relate between them? I see even PK value is different for them

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





Sorry for simple picture

here is a new detailed pics from me

[URL=http://imageshack.us/photo/my-images/7/44444444444444444444444u.png/][/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]

[URL=http://imageshack.us/photo/my-images/830/333333333333333333333y.png/][/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]

thanks for replies

============

forgot to mention

everytime taken from local time in each branch computer
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-16 : 12:03:01
didnt understand why you're storing date values like this in two different fields and also in this format. if you had used datetime fields manipulations would have been much easier.
for current format its rather messy. here's a start for you to use in your query


DECLARE @SDate varchar(10),@STime varchar(10),@Edate varchar(10),@ETime varchar(10)

SELECT @SDate ='20-01-2012',@STime ='07.00',@Edate ='22-01-2012',@ETime ='15.31'

SELECT CONVERT(varchar(5),DATEDIFF(ss,CONVERT(datetime,@SDate+ ' ' + REPLACE(@STime,'.',':'),103),CONVERT(datetime,@Edate + ' ' + REPLACE(@ETime,'.',':'),103))/3600) + '.' +
CONVERT(varchar(10),(DATEDIFF(ss,CONVERT(datetime,@SDate+ ' ' + REPLACE(@STime,'.',':'),103),CONVERT(datetime,@Edate + ' ' + REPLACE(@ETime,'.',':'),103))% 3600.0)/60.0)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -