mysql how to make a query in sql to use in c++ code on counting the borrowing report in every month

4si2a6ki  于 2022-12-22  发布在  Mysql
关注(0)|答案(1)|浏览(130)

I want to make a query to count borrowing report every month . But i'd saved my data in unixtime.

tablename:borrow
attributes:borrowingID,dateOfBorrow,dateOfReturn,statusBook

For example the dateOfBorrow is 167077440 and i just want to count the specific month for jan,feb,etc..
i am expecting

| Month | Total |
| ------| ----- |
|  Jan  |   2   |
|  Feb  |   5   |
|  Mar  |   5   |
...etc
nbnkbykc

nbnkbykc1#

select from_unixtime(167077440),from_unixtime(167077440,'%b')

+--------------------------+-------------------------------+
| from_unixtime(167077440) | from_unixtime(167077440,'%b') |
+--------------------------+-------------------------------+
| 1975-04-18 19:24:00      | Apr                           |
+--------------------------+-------------------------------+
1 row in set (0.001 sec)

See manual https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_from-unixtime and https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format
But are you really interested in 1975?

相关问题