(basically trying to get inactive users who haven't done any events in the past 30 days)
table is structured like this -
user ID // device ID // event name // event_date
How do i get list of users who have event recorded in a specific time period?
(basically trying to get inactive users who haven't done any events in the past 30 days)
table is structured like this -
user ID // device ID // event name // event_date
How do i get list of users who have event recorded in a specific time period?
Add condition in where clause
SELECT user_id, device_id, event_name, event_date FROM user
WHERE event_date >= DATEADD(day,-30,GETDATE())
and event_date <= getdate()
Or use DateDiff
SELECT user_id, device_id, event_name, event_date FROM user
WHERE DATEDIFF(day,event_date,GETDATE()) between 0 and 30
<?php
$fromDate = "2020-08-01 00:00:00"; //replace it with starting date in same format
$toDate = "2020-08-10 23:59:59"; //replace it with ending date in same format
//replace with your table name and make
//make sure datatype of event_date column must be "DATETIME" in sql database
$query = "SELECT * FROM EVENT_TABLE_NAME where event_date >= $fromDate and event_date <= $toDate";
You can execute this query and you will get list of records which are occurred in given date range.