如何独自获得分钟部分而没有秒 [英] how to get the minute part alone without seconds

查看:77
本文介绍了如何独自获得分钟部分而没有秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其中CONVERT(VARCHAR,lastsenddate,101)= CONVERT(VARCHAR,getdate(),101)和---

在上面的iam中,将lastsendate与正在工作的currentdate进行比较,并补充一点,我需要检查lastsendate的分钟"是否与当前日期时间分钟匹配.

需要单独获得lastsendates时针和分针
而currentdates小时和分钟部分,我不需要秒.

请帮我

where CONVERT(VARCHAR,lastsenddate,101)=CONVERT(VARCHAR,getdate(),101)and ---

in the above iam comparing the lastsendate with the currentdate which is working and adding to that i need to check whether the ''minute '' of lastsendate matches with the current datetime minute.

need to the get lastsendates hour and minute part alone
and the currentdates hour and mniute part alone i donot require seconds.

pls help me out

推荐答案



如果可以帮助,请尝试此示例...

Hi,

Try this sample if could help...

where lastsenddate between cast(@From + ' 00:00:00' as datetime) and cast(@To + ' 23:59:59' as datetime)) 




请投票表决是否有帮助,以便其他人可以考虑作为答案...

问候




Please vote if could help so that others may consider as an answer...

Regards,


尝试一下:

Try this :

select datepart(mi,getdate())





where CONVERT(VARCHAR,LastSendDate,101)=CONVERT(VARCHAR,getDate(),101) and DATEPART(hh,LastSendDate)=DATEPART(hh,getDate()) and DATEPART(mi,LastSendDate)=DATEPART(mi,getDate())


如果您要比较两次DATEDIFF [
In case you were going to compare two times DATEDIFF[^] will help you , to collect times that have ocurred just in the same minute as now try this :

where DATEDIFF(MINUTE, lastsenddate, GETDATE())=0 and 
        DATEDIFF(SECOND, lastsenddate, GETDATE())<60



这将为您提供与现在相同的lastsenddates.

如果您要进行其他更改,请执行此查询并在where子句中使用其功能:



This will give you lastsenddates whose minutes are the same as now.

If you want other alternations execute this query and use its functions in your where clause :

select GETDATE(), DATEPART(HOUR, GETDATE()),DATEPART(MINUTE, GETDATE()) 



希望对您有所帮助.



Hope it helps.


这篇关于如何独自获得分钟部分而没有秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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