Select * Timestamp BETWEEN NOW and NOW - 1 Hour

Posted on 2006-04-11
Last Modified: 2008-02-01
I would like to know the proper syntax for selecting rows in a SQL Server Database Table where the TimeStamp for that Table is between the current time and that time minus one hour.

Question by:Argblat
    LVL 50

    Accepted Solution

    you do mean timestamp as a datetime value , rather than a Timestamp column ?

    if so

    select *
     from yourtable
     Where yourTimestamp between dateadd(h,-1,getdate()) and getdate()
     order by yourtimestamp desc
    LVL 44

    Assisted Solution

    Hi Argblat,

    Select * From MyTable Where MyDateTimeField Between GetDate() And DateAdd(hour,-1,GetDate())

    Tim Cottee
    LVL 44

    Expert Comment


    Got it the wrong way round!


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now