SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 difference between two timestamps in minutes
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sanjay_hartford
Starting Member

7 Posts

Posted - 04/03/2013 :  12:50:22  Show Profile  Reply with Quote
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) then

I get error as "inconsistant data type.


Please suggest the answers. I appriciate the help.

Thanks.

russell
Pyro-ma-ni-yak

USA
5072 Posts

Posted - 04/03/2013 :  12:53:28  Show Profile  Visit russell's Homepage  Reply with Quote
What data type is TS.LAST_TIMESTMP?
Go to Top of Page

sanjay_hartford
Starting Member

7 Posts

Posted - 04/03/2013 :  13:01:40  Show Profile  Reply with Quote
it is of timestamp.
Go to Top of Page

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1052 Posts

Posted - 04/03/2013 :  13:32:55  Show Profile  Reply with Quote
SELECT DateDiff(minute,LAST_TIMESTMP ,CURRENT_TIMESTAMP) FROM TableName

Cheers
MIK
Go to Top of Page

sanjay_hartford
Starting Member

7 Posts

Posted - 04/03/2013 :  13:38:43  Show Profile  Reply with Quote
Thanks Mik. I was trying below query

select LAST_TIMESTMP, current_timestamp, DateDiff(minute,LAST_TIMESTMP ,CURRENT_TIMESTAMP) from
CAQH_O.transaction_status
where
transactionreferenceid='20121114161324042270_000545';

but it is complaning about DateDiff function saying, "DATEDIFF": invalid identifier" . Does it mean, it is not recognizing this function.

suggest me.

Thanks,
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 04/03/2013 :  13:50:17  Show Profile  Reply with Quote
are you using sql server? DATEDIFF is a function in SQL Server

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

sanjay_hartford
Starting Member

7 Posts

Posted - 04/03/2013 :  14:03:59  Show Profile  Reply with Quote
I am trying to run in Oracle SQL Developer 2005.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 04/03/2013 :  14:21:22  Show Profile  Reply with Quote
then datediff wont work. see documentattion for corresponding function in Oracle.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

sanjay_hartford
Starting Member

7 Posts

Posted - 04/03/2013 :  14:34:23  Show Profile  Reply with Quote
any links, where I could see the same?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 04/03/2013 :  14:42:07  Show Profile  Reply with Quote
try in some oracle forums. This is ms sql server forum

www.orafaq.com

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000