Home PHP MySQL query shows the current date of the table by date before 1 month
Reply: 0

PHP MySQL query shows the current date of the table by date before 1 month

user1301
1#
user1301 Published in July 16, 2018, 8:34 pm

I will create a notification system with 1 month notice before deadline. I have a problem displaying a date that coincides with the current date. I want to show that appears only date today from the deadline date before 1 month deadline.

My tabel = notif :

+------+------------+------------+
| id   | name       | deadline   |
+------+------------+------------+
| 01   | Daniel     | 2018-02-13 |
| 02   | Elwin      | 2018-02-12 |
| 03   | Dika       | 2018-02-13 |
+------+------------+------------+

For example : date today = 2018-01-13
report table what i want :

+------+------------+------------+------------+
| id   | name       | deadline   | alert_now  |
+------+------------+------------+------------+
| 01   | Daniel     | 2018-02-13 | 2018-01-13 |
| 03   | Dika       | 2018-02-13 | 2018-01-13 |
+------+------------+------------+------------+

My Query in model of codeigniter :

public function notification(){
        $query=$this->db->query('SELECT *, DATE_SUB(deadline, INTERVAL 1 MONTH) as alert_now FROM notif WHERE now() = DATE_SUB(deadline, INTERVAL 1 MONTH)');
        return $result=$query;
    }

Note : Sorry, my english is poor. Thank you.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.35296 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO