Skip to content
Advertisement

find active records from table based on date time in php and sql server

I need to fetch active records from my table. A record is active means it is not expired and the expiration time is 2 minutes after record is generated. I am using sql server database. Here is the structure for my table enter image description here

And my code is as follows

JavaScript

I need the condition for DateGenerated as

JavaScript

How can I implement this condition in my query

Advertisement

Answer

Another possible approach is to let the SQL Server do the check using CURRENT_TIMESTAMP and DATEADD():

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement