14,329,915 members
Rate this:
See more:
i have one table like this

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

i want time difference..

Posted
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:

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```

Cheers
Rate this:

Solution 3

Timediff in seconds?
See DateDiff here
v3
Rate this:

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)

Top Experts
Last 24hrsThis month
 OriginalGriff 194 Richard MacCutchan 185 Visweswaran N 130 RickZeeland 110 CPallini 70
 OriginalGriff 2,313 Maciej Los 1,330 phil.o 958 Richard Deeming 590 Richard MacCutchan 401

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