Mysql query with grouping by day and time range

Asked

Viewed 187 times

0

Good afternoon. I’m putting together a page with reports based on the amount of sales a bar has made.

only if there is a problem. I need to generate a sales report per day until then I managed by grouping "SELECT count(id) total, DATE(data_abertura) abertura from vendas group by abertura limit 15";

only that this is returning wrong for the following reason that the bar opens on the 19th and will only close on the 20th so a commando can be opened on the 20th midnight and a half and the bar opened on the 19th and this sale should be counted as the 19th.

Any hint about logic or query on how to resolve this impasse?

  • Your date is in the correct datetime format ? if yes: SELECT Count(id) total, DATE(opening date) open FROM sales WHERE hora_da_comanda > dat_do_dia_hora_de_abertua AND hora_da_comanda < dat_do_dia_mais_um_dia_hora_de_lock GROUP BY opening limit 15

  • @Jasar Orion Anthraxisbr may be right, but if we can create a table with a single DATA line that will be populated in the system OPENING, then ALL sales would take the date of that table and if necessary, would create another date field in the sales table to store the actual DATE the order was placed. They are suggestions :) I hope they can throw some light or new direction in solving your problem :)

  • I believe that what you want to do is calculate by the date of the box, another column with the code of the box would solve the problem.

  • understood then do not have this table in db to store the date. I thought the following I will force a specific date time pro Serv type 12 hours less then the day of the guy does not start at 00 and yes half day. Only doing this would solve it.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.