title: Comparing two dates minutes in sql server
body: <p>What I'm trying to do is comparing a DateTime variable and a date inside a table in sql server if the the differece between those two date are less than 30 min the select query will return some values I'm using c# to send the DateTime variable</p>
  
  <pre><code>string query = "Select * from LoginAttempts where IP_ADDRESS='" + Ipadress + "' and ATTEMPTS&lt;"+MaxLoginAttempts+" and (GETDATE()-LOGIN_DATE)&lt;30";
  </code></pre>
  
  <p><code>and (GETDATE()-LOGIN_DATE)&lt;30</code> I know this is a wrong statement but how should I fix it?</p>