May 10, 2006 #1 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
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 Mar 10, 2006 642 US DATEDIFF ( datepart , startdate , enddate ) Upvote 0 Downvote
May 10, 2006 #3 jbenson001 Programmer Jan 7, 2004 8,172 US you would have to convert them to a valid datetime format then use the datediff function. Upvote 0 Downvote
May 10, 2006 #5 vongrunt Programmer Mar 8, 2004 4,863 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]