Kyle
Kyle

Reputation: 33691

SELECT rows with time 30 minutes or less?

I have found ways on google to select rows within X amount of days, but I have a datetime column in my SQL Server 2008 table and would like to get the rows that have a datetime within the last 30 minutes.

Can anyone show me how to do this?

Thanks.

Upvotes: 2

Views: 11998

Answers (3)

Manish Mulani
Manish Mulani

Reputation: 7375

Use DATEADD or DATEDIFF

Upvotes: 0

done_merson
done_merson

Reputation: 2998

WHERE column >= DATEADD(mi, -30, GETDATE())

Upvotes: 8

Habib
Habib

Reputation: 223187

Use DateAdd

select * from
yourtable
where DateCol > DateADD(mi, -30, GetDate())

Upvotes: 2

Related Questions