Home » Php » SQL to Filter timestamp using the where clause on day or time

SQL to Filter timestamp using the where clause on day or time

Posted by: admin June 30, 2018 Leave a comment

Questions:

I am having this table and i am trying to filter records based on day or based on month from the date_time_stamp field

+---------------+-----------------+
| name          | date_time_stamp |
+---------------+-----------------+
| John          |      1329828975 |
+---------------+-----------------+
| Ken           |      1428728929 |
+---------------+-----------------+
| Bennedict     |      1526758965 |
+---------------+-----------------+
| Lily          |      1725498952 |
+---------------+-----------------+

The following SQL was only able to get the day, month and year from the table but adding a WHERE day=5 flags error

SELECT us.lessons_ID,
us.from_timestamp,
us.users_LOGIN,
       DAY(FROM_UNIXTIME(us.from_timestamp)) as 'day',
       MONTH(FROM_UNIXTIME(us.from_timestamp))  as 'month',
        YEAR(FROM_UNIXTIME(us.from_timestamp))  as 'year'
   FROM users_to_lessons  us

so my question is how do i filter records from this table were month equal May or June e.t.c or filter based on day or even filter based on Month, Day and Year

Would be glad if someone can give me a clue

Answers: