Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


difference


difference

Author
Message
kumar99ms
kumar99ms
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 550
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
seth delconte
seth delconte
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1627 Visits: 1360
The answer is 6 seconds. Wink

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
Matt Miller (#4)
Matt Miller (#4)
SSCertifiable
SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)

Group: General Forum Members
Points: 7641 Visits: 18084
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?
David O
David O
SSC-Enthusiastic
SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)

Group: General Forum Members
Points: 191 Visits: 913
Once you get your formatting issues fixed the function is datediff. Check out Books on line for the details of the function.
seth delconte
seth delconte
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1627 Visits: 1360
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
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45151 Visits: 39923
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

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search