$m = squery("SELECT date FROM attendance WHERE id=7" This query returns array of dates.. I Want to extract only month name from this array.. Thanxs.
Assuming your date column is of type date then,
Let a dummy table data be as follows,
Table
+------+------------+ | id | DDate | +------+------------+ | 7 | 2018-06-21 | | 7 | 2018-06-22 | | 7 | 2018-06-23 | | 7 | 2018-06-24 | | 7 | 2018-06-25 | | 7 | 2018-06-26 | +------+------------+ Query 1 : to get the month number
select month(DDate) as Mnth from MBO where id=7 group by Mnth; +------+ | Mnth | +------+ | 6 | +------+ Query 2 : To get month name
select monthname(DDate) as Mnth from MBO where id=7 group by Mnth; +------+ | Mnth | +------+ | June | +------+ You can change your SQL as above to assign your variable to desired value,
Note: it is assumed that for id=7 a single month dates would be present in table hence added a group by to get unique value. Else you may need to add more conditions to get a single value, or if you just need to get any month then a limit 1 will do.
date?datecolumn?select monthname( date )??