Question about Date function in PHP and MySQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
j.smith1981
Forum Newbie
Posts: 7
Joined: Mon Apr 06, 2009 3:48 pm

Question about Date function in PHP and MySQL

Post by j.smith1981 »

I have a big question.

At work, the purchasing manager requires a daily report actioned each day.

The time of the report will be actioned at 3pm.

It requires all orders back dated to the previous day after 3pm, would this be possible?

What kind of function would I have to write if it was basically just 2 columns of the date in MySQL and the Product code?
Orders table (after join):

Code: Select all

 
Order ID            SKU                 Product name        QTY_ordered (of item only)
1                      BRLC01BK         LC01BK                20
1                      BRLC02BK         LC02BK                10
2                      BRLC01BK         LC01BK                10
 
The overall aim of the above is to combine the 2 items LC01BK in one row in excel later on, so that we know what to order in a concise manner when ordering products from our suppliers.

Could this be done using a dynamic date that looks back to the previous date and time?

Obviously taking the date value of todays date and then looking back to the previous date after 3pm?

Thanks,
Jeremy.
nyoka
Forum Commoner
Posts: 45
Joined: Thu Apr 09, 2009 12:53 pm

Re: Question about Date function in PHP and MySQL

Post by nyoka »

Check http://dev.mysql.com/doc/refman/5.0/en/ ... fiers.html for the GROUP BY option and make sure you use SUM(quantity) within the query.
Post Reply