Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

SQL get last 5 minutes data

-- for last 5 mins 
SELECT * 
FROM table_name
WHERE  (SELECT  CONVERT(char(5),SYSDATETIMEOFFSET() AT TIME ZONE 'Central Standard Time', 108))                        
  BETWEEN   CONVERT(VARCHAR(5),CreationDate,108) AND CONVERT(VARCHAR(5), DATEADD(mi, 5,CreationDate),108)                          

-- for last 15 mins 
SELECT * 
FROM table_name
WHERE  (SELECT  CONVERT(char(5),SYSDATETIMEOFFSET() AT TIME ZONE 'Central Standard Time', 108))                        
  BETWEEN   CONVERT(VARCHAR(5),CreationDate,108) AND CONVERT(VARCHAR(5), DATEADD(mi, 15,CreationDate),108)                          
 
PREVIOUS NEXT
Tagged: #SQL #minutes #data
ADD COMMENT
Topic
Name
5+5 =