Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sanjay_hartford
Starting Member
7 Posts |
Posted - 2013-04-03 : 12:51:05
|
hi Friends,I need to find the difference in two timestamps and covert the difference in minutes. Once that is done, I need to check, if that difference in greater than 15 minutes or not.I think, I would need to move the difference to a number so that I can compare it with 15. I am not sure. Table A has a column Last_Timestamp. Another timestamp is CURRENT_TIMESTAMP. I am trying below things - > A) IF (SELECT 24*60*(CURRENT_TIMESTAMP - Last_Timestamp) From TransactionStatus TS Where TS.TransactionReferenceID= Key) > 15 B) SELECT (1440 * (TS.LAST_TIMESTMP - CURRENT_TIMESTAMP)) INTO emailTimeDifference FROM CAQH_O.transaction_status TS WHERE TS.transactionreferenceid = variableKey.EMAILKEY; IF (emailTimeDifference > 15) thenI get error as "inconsistant data type. Please suggest the answers. I appriciate the help.Thanks. |
|
russell
Pyro-ma-ni-yak
5072 Posts |
|
sanjay_hartford
Starting Member
7 Posts |
Posted - 2013-04-03 : 13:10:07
|
yes, I just thought, If I can get reply faster. I need to complete this today. will keep in mind. |
|
|
harlingtonthewizard
Constraint Violating Yak Guru
352 Posts |
Posted - 2013-04-03 : 20:50:55
|
Declare @TimeA DateTimeDeclare @TimeB DateTimeSET @TimeA = (Select '4/4/2013 17:00:00')SET @TimeB = (Select '4/4/2013 17:16:00')Select *, Case When [TimeDifference (minutes)] > 15 Then 'Yes' Else 'No' End [Over15Minutes]From (Select DATEDIFF(MINUTE, @TimeA, @TimeB) As [TimeDifference (minutes)]) d |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-04 : 01:17:22
|
quote: Originally posted by harlingtonthewizard Declare @TimeA DateTimeDeclare @TimeB DateTimeSET @TimeA = (Select '4/4/2013 17:00:00')SET @TimeB = (Select '4/4/2013 17:16:00')Select *, Case When [TimeDifference (minutes)] > 15 Then 'Yes' Else 'No' End [Over15Minutes]From (Select DATEDIFF(MINUTE, @TimeA, @TimeB) As [TimeDifference (minutes)]) d
Please try to pass date values in unambigous formatsee reason herehttp://visakhm.blogspot.in/2011/12/why-iso-format-is-recommended-while.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|