Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference Between Two Times

Status
Not open for further replies.

lfcmd

Programmer
May 3, 2006
14
IE
If i have two time fields stored as type nvarchar
how can i find the differnce in time between the 2

time
12:02
12:38

returning 0:36
 
you would have to convert them to a valid datetime format then use the datediff function.
 
This should work for positive values < 24h:
Code:
select convert(varchar(5), convert(datetime, '12:38') - '12:02', 108)
But [!]n[/!]varchar... [shocked].

------
[small]<this is sig>
select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')
</this is sig>[/small]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top