Page 1 of 1

Month and Yearly Reports

Posted: Tue Feb 17, 2004 2:34 am
by phppick
Hi,

i am using Postgres Database and PHP in my Project, i have got some doubts regarding Month and Year functions.

I am passing Date(17-Feb-2004) to my PHP Page,

I want to Calculate, Monthly & Yearly Reports based on Input.

Suppose we have Orders table, (in that we have OrderNo, OrderDate, CustomerName etc)

I need to know, in Feb how many orders i got? and in January etc etc.

and also i will input Year from Combobox like 2000,2002,2003.
I need to know how many Orders i got in Year 2000,.. Year 2002 etc etc, based on Year Input.

Posted: Tue Feb 17, 2004 5:49 am
by patrikG
Please elabourate on how PHP receives the data.

Are you passing the date in an array? As part of the general order-array?
Is it somehow akin to this:

Code: Select all

$orders["productNumber"]=192834;
$orders["description"]="Funny Bunny"
$orders["ordered"]="17-Feb-2004"
?

For working with dates in general, have a look at [php_man]mktime[/php_man], [php_man]strftime[/php_man] and [php_man]date[/php_man].

Posted: Tue Feb 17, 2004 2:40 pm
by Weirdan
hmmm... you can do something like:

Code: Select all

select concat(year(dateinsert),'-',month(dateinsert)),count(*) from Order group by concat(year(dateinsert),'-',month(dateinsert))
Don't know whether it would work in Postgres, but in MySQL it works like a charm ;)

Elobrate

Posted: Tue Feb 17, 2004 8:16 pm
by phppick
Hi patrikG,

I am just using JavaScript Date Picker for Passing the Date to PHP date..

The only Variable i am passing is "Date", no other. By passing date i wna to view monthly and yearly Reports from Postgres Database.

Tq,

Posted: Wed Feb 18, 2004 2:44 am
by patrikG
The SQL seems to run fine - so check in the database how many rows you are expecting back from that table.