May 10, 2006 #1 lfcmd Programmer Joined May 3, 2006 Messages 14 Location 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
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
May 10, 2006 #2 macleod1021 Programmer Joined Mar 10, 2006 Messages 642 Location US DATEDIFF ( datepart , startdate , enddate ) Upvote 0 Downvote
May 10, 2006 #3 jbenson001 Programmer Joined Jan 7, 2004 Messages 8,172 Location US you would have to convert them to a valid datetime format then use the datediff function. Upvote 0 Downvote
May 10, 2006 Thread starter #4 lfcmd Programmer Joined May 3, 2006 Messages 14 Location IE cheers guys Upvote 0 Downvote
May 10, 2006 #5 vongrunt Programmer Joined Mar 8, 2004 Messages 4,863 Location HR This should work for positive values < 24h: Code: select convert(varchar(5), convert(datetime, '12:38') - '12:02', 108) But [!]n[/!]varchar... . ------ [small]<this is sig> select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/') </this is sig>[/small] Upvote 0 Downvote
This should work for positive values < 24h: Code: select convert(varchar(5), convert(datetime, '12:38') - '12:02', 108) But [!]n[/!]varchar... . ------ [small]<this is sig> select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/') </this is sig>[/small]