• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 719
  • Last Modified:

Select * Timestamp BETWEEN NOW and NOW - 1 Hour

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.

-Mike
0
Argblat
Asked:
Argblat
  • 2
2 Solutions
 
LowfatspreadCommented:
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
0
 
TimCotteeCommented:
Hi Argblat,

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

Tim Cottee
0
 
TimCotteeCommented:
Argblat,

Got it the wrong way round!


Tim
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now