October 15, 2008 at 12:20 pm
Hi Every body,
How can i find difference between these two could any please give some quire for this
14:12:43 CDT 06/14/2007
and
14:12:49 CDT 06/14/2007
Thanks
October 15, 2008 at 12:54 pm
The answer is 6 seconds. 😉
But seriously, what kind of date format is that? I couldn't find any examples of converting from that format.
_________________________________
seth delconte
http://sqlkeys.com
October 15, 2008 at 12:57 pm
Same question, asked in a new package -
http://www.sqlservercentral.com/Forums/FindPost585845.aspx
and
http://www.sqlservercentral.com/Forums/FindPost585851.aspx
No matter what you do with these - you will need to convert them first, then do whatever math you need to do.
You REALLY should keep these all together, since they are so closely related. You give the impression you're not reading the answers you're being given.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
October 15, 2008 at 12:58 pm
Once you get your formatting issues fixed the function is datediff. Check out Books on line for the details of the function.
October 15, 2008 at 1:34 pm
I agree, I think there's no way around the fact that you have to convert first. This should put you in the right direction for converting to standard MSSQL datetime format:
declare @oldDate varchar(50)
select @oldDate = '14:12:43 CDT 06/14/2007'
select convert(datetime,SUBSTRING(@oldDate,CHARINDEX(' ',@oldDate)+6,len(@oldDate))+' '+
SUBSTRING(@oldDate,0,CHARINDEX(' ',@oldDate)))
You can use a similar statement with an update or insert operation, then you will be free to use datediff or whatever to do the comparing!
_________________________________
seth delconte
http://sqlkeys.com
October 15, 2008 at 7:02 pm
David O (10/15/2008)
Once you get your formatting issues fixed the function is datediff. Check out Books on line for the details of the function.
Actually, once converted, you can just subtract one from the other and format it in the hh:mm:ss.mmm format (24 hour) using CONVERT. And, be careful using DATEDIFF for days... it can give you and extra day if the times are just right.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply