0

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
Alan Birtles
  • 32,622
  • 4
  • 31
  • 60

1 Answers1

0
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?

P.Salmon
  • 17,104
  • 2
  • 12
  • 19