By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,925 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Showing newer recordset

P: 6
I am a bit new to coding SQL in the sense of the code. I trying to get it to show only records like posted with in 2 minutes of current time. i got the following code
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM dbo.RSonline WHERE DateDiff(m,RSdate,GetDate()) BETWEEN 0 AND 1
  3. ORDER BY RSuser ASC
any ideas where i am going wrong. the database sees the RSdate cell as YYYY-MM-DD HH:MM:SS.
Nov 13 '12 #1

✓ answered by Rabbit

m is for month. Use mi or n for minutes.

However, it would be more accurate for you to use seconds and see if it is within 120 seconds. With date diff, it is almost always better to use one grain lower.

Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,430
m is for month. Use mi or n for minutes.

However, it would be more accurate for you to use seconds and see if it is within 120 seconds. With date diff, it is almost always better to use one grain lower.
Nov 13 '12 #2

P: 6
My final code for others reading this as it works
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM dbo.RSonline
  3. WHERE DateDiff(N,RSdate,GetDate()) BETWEEN 0 AND 1
Nov 14 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.