Showing newer recordset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geekyninja
    New Member
    • Aug 2011
    • 6

    Showing newer recordset

    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
    Code:
    SELECT *
    FROM dbo.RSonline WHERE DateDiff(m,RSdate,GetDate()) BETWEEN 0 AND 1
    ORDER BY RSuser ASC
    any ideas where i am going wrong. the database sees the RSdate cell as YYYY-MM-DD HH:MM:SS.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    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.

    Comment

    • geekyninja
      New Member
      • Aug 2011
      • 6

      #3
      My final code for others reading this as it works
      Code:
      SELECT *
      FROM dbo.RSonline
      WHERE DateDiff(N,RSdate,GetDate()) BETWEEN 0 AND 1

      Comment

      Working...