Click here to Skip to main content
14,329,915 members
Rate this:
Please Sign up or sign in to vote.
See more:
i have one table like this


starting time ending time
16:26:46:235 16:26:50:924

i want time difference..

please help me out
Posted
Comments
digimanus 1-Sep-15 7:56am
   
Timediff in seconds?
See DateDiff here
CHill60 1-Sep-15 8:00am
   
As per your earlier comment to me - that's the answer!
Maciej Los 1-Sep-15 8:06am
   
What have you tried? Where are you stuck?
digimanus 1-Sep-15 8:28am
   
done
Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi,

Check this...Sql time difference between two dates result in hhmmss[^]

...with little modifications

declare @StartDate time, @EndDate time

select @StartDate = '16:26:46:235&',@EndDate='16:26:50:924';

SELECT CONVERT(VARCHAR(12), DATEADD(MS, DATEDIFF(MS, @StartDate, @EndDate), 0), 114) AS TimeDiff



Hope this will help you.

Cheers
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

Timediff in seconds?
See DateDiff here
   
v3
Rate this:
Please Sign up or sign in to vote.

Solution 2

Try the below code:

SELECT  CAST(DATEDIFF(HOUR, '16:26:46:235', '16:26:50:924') AS VARCHAR)
         + ':' + CAST(DATEDIFF(MINUTE, '16:26:46:235', '16:26:50:924') AS VARCHAR)
         + ':' + CAST(DATEDIFF(SECOND, '16:26:46:235', '16:26:50:924') AS VARCHAR)
         + ':' + CAST(DATEDIFF(MILLISECOND, '16:26:46:235', '16:26:50:924') AS VARCHAR)


This should give you what you are looking for.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100