Month and Yearly Reports

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
phppick
Forum Commoner
Posts: 57
Joined: Thu Aug 14, 2003 5:59 am

Month and Yearly Reports

Post 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.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post 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].
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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 ;)
phppick
Forum Commoner
Posts: 57
Joined: Thu Aug 14, 2003 5:59 am

Elobrate

Post 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,
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

The SQL seems to run fine - so check in the database how many rows you are expecting back from that table.
Post Reply