Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
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
Posted

Hi,

Try this sample if could help...

C#
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,
 
Share this answer
 
Comments
ashok_89 15-Dec-11 5:07am    
really great ,it works sir and i also need to remove the date part also
Al Moje 15-Dec-11 20:46pm    
Thanks, Could you click the vote radio button so that others may see and consider as an answer? The highest vote is on the right side (5)...
sravani.v 15-Dec-11 23:42pm    
My 5!
Try this :

SQL
select datepart(mi,getdate())


SQL
where CONVERT(VARCHAR,LastSendDate,101)=CONVERT(VARCHAR,getDate(),101) and DATEPART(hh,LastSendDate)=DATEPART(hh,getDate()) and DATEPART(mi,LastSendDate)=DATEPART(mi,getDate())
 
Share this answer
 
v2
Comments
ashok_89 15-Dec-11 5:30am    
sir i dont know how to use in this query just show me an sample
ashok_89 16-Dec-11 0:25am    
thanks a lot siir its really awesome, thank u very much
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 :

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


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 :
SQL
select GETDATE(), DATEPART(HOUR, GETDATE()),DATEPART(MINUTE, GETDATE()) 


Hope it helps.
 
Share this answer
 

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