I want to retrieve records for last 30 minutes in a table. How to do that? Below is my query..
select * from
[Janus999DB].[dbo].[tblCustomerPlay]
where DatePlayed < CURRENT_TIMESTAMP
and DatePlayed >
(CURRENT_TIMESTAMP-30)
I want to retrieve records for last 30 minutes in a table. How to do that? Below is my query..
select * from
[Janus999DB].[dbo].[tblCustomerPlay]
where DatePlayed < CURRENT_TIMESTAMP
and DatePlayed >
(CURRENT_TIMESTAMP-30)
Change this (CURRENT_TIMESTAMP-30)
To This: DateADD(mi, -30, Current_TimeStamp)
To get the current date use GetDate().
MSDN Link to DateAdd Function
MSDN Link to Get Date Function
Have a look at using DATEADD
something like
SELECT DATEADD(minute, -30, GETDATE())
Use:
SELECT *
FROM [Janus999DB].[dbo].[tblCustomerPlay]
WHERE DatePlayed < GetDate()
AND DatePlayed > dateadd(minute, -30, GetDate())
SQL Server uses Julian dates so your 30 means "30 calendar days". getdate() - 0.02083 means "30 minutes ago".