Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working with a mobile application.Here there is a database field 'deactivation_date' which tells the deactivation time of the customer.I have to find out the customers those who are deactivate within 15 minutes.We can use 'current_date' to compare with 'deactivation_date' .(database fields are customer_id,customer_name,deactivation_date etc.,).Please help.
Posted

Use DATEDIFF[^] for the comparison. Something like:
SQL
... DATEDIFF(minute, GETDATE(), deactivcationdate) <= 15...
 
Share this answer
 
Comments
Sandeep Mewara 11-May-12 2:10am    
Looks like similar stuff what I shared. 5!
Wendelius 11-May-12 11:01am    
Thanks Sandeep :)
Use MSDN: DATEDIFF (Transact-SQL)[^]

Try:
SQL
SELECT
  customer_id,
  customer_name
FROM
  mstCustomers
WHERE
  DATEDIFF(minute, GETDATE(), deactivation_date) <= 15
 
Share this answer
 
Comments
Wendelius 11-May-12 1:28am    
For some reason seems very good to me :) 5.
Sandeep Mewara 11-May-12 2:10am    
Thanks Mika.
Try:
SQL
SELECT * FROM MyTable WHERE deactivation_date < DATEADD(minute, -15, GETDATE())
 
Share this answer
 
Comments
Wendelius 11-May-12 1:35am    
Yep. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900