How to get last 5 mins records from SQL table.
E.g: I have one table name called Student.
ID Name StartTime
-- ---------- ----------------------
1 abc 2016-05-18 08:00:29.587
2 xxx 2016-05-18 08:05:30.287
3 xyz 2016-05-18 08:10:30.287
Consider now the Time is 8:15am. I would like to get last 5mins record from "Student"
table.
E.g: I need "xyz" user information.
I tried below queries not working.
select * from Student where startTime is not null and startTime < GetDate() and startTime > dateadd(minute, -5, GetDate())
But i am getting null values from student table.
How to do it. please help me to solve.
select * from Student where startTime is not null and startTime > DATEADD(minute, -5, GETUTCDATE())
try this code
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments