sqserver中的分钟到期时间 [英] Minute Expiry in sqserver

查看:106
本文介绍了sqserver中的分钟到期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用移动应用程序.这里有一个数据库字段"deactivation_date",它告诉客户停用时间.我必须找出在15分钟内停用的客户.我们可以使用"'current_date'与"deactivation_date"进行比较.(数据库字段为customer_id,customer_name,deactivation_date等.)请提供帮助.

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.

推荐答案

使用 DATEDIFF [
Use DATEDIFF[^] for the comparison. Something like:
... DATEDIFF(minute, GETDATE(), deactivcationdate) <= 15...


使用 MSDN:DATEDIFF(Transact-SQL) [ ^ ]

试试:
Use MSDN: DATEDIFF (Transact-SQL)[^]

Try:
SELECT
  customer_id,
  customer_name
FROM
  mstCustomers
WHERE
  DATEDIFF(minute, GETDATE(), deactivation_date) <= 15


尝试:
SELECT * FROM MyTable WHERE deactivation_date < DATEADD(minute, -15, GETDATE())


这篇关于sqserver中的分钟到期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆