469,286 Members | 2,476 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

Mysql query

Hi,

I have a database with a date field. And I would like to see the report
grouped by a ceratin month and year, how can I do that without multiple
queries?

Albert Ahtenberg
Jul 16 '05 #1
5 11573
What format is the date field stored in?

Is there a day, month, and year field (separate)?
Is it a timestamp?
Is it something else?

-Jim Stapleton

"Albert Ahtenberg" <do**********@this.address> wrote in message
news:bd**********@tabloid.uwaterloo.ca...
Hi,

I have a database with a date field. And I would like to see the report
grouped by a ceratin month and year, how can I do that without multiple
queries?

Albert Ahtenberg

Jul 16 '05 #2
It is the MySql DATE type. looks like (DD-MM-YYYY).

"Steven James Samuel Stapleton" <st**********@mps.ohio-state.edu> wrote in
message news:mcgHx12drhfu@ohstpy...
What format is the date field stored in?

Is there a day, month, and year field (separate)?
Is it a timestamp?
Is it something else?

-Jim Stapleton

"Albert Ahtenberg" <do**********@this.address> wrote in message
news:bd**********@tabloid.uwaterloo.ca...
Hi,

I have a database with a date field. And I would like to see the report
grouped by a ceratin month and year, how can I do that without multiple
queries?

Albert Ahtenberg


Jul 16 '05 #3

First get a real email address if you want real replies.

On Fri, 27 Jun 2003 20:54:25 -0400, Albert <do**********@this.address> wrote:
It is the MySql DATE type. looks like (DD-MM-YYYY). ^^^^^^^^^^
This isn't a MySQL date format.
select * from mydatabase where datefield like "2003-07%";

This works for me.


"Steven James Samuel Stapleton" <st**********@mps.ohio-state.edu> wrote in
message news:mcgHx12drhfu@ohstpy...
What format is the date field stored in?

Is there a day, month, and year field (separate)?
Is it a timestamp?
Is it something else?

-Jim Stapleton

"Albert Ahtenberg" <do**********@this.address> wrote in message
news:bd**********@tabloid.uwaterloo.ca...
> Hi,
>
> I have a database with a date field. And I would like to see the report
> grouped by a ceratin month and year, how can I do that without multiple
> queries?
>
> Albert Ahtenberg
>
>



--
Michael Vore, W3CCV M-ASA [Ka8]; WHIRL, ABC; CAW, CW, AAW
http://mike.vorefamily.net/ohmywoodness <-Custom Woodworking
http://mike.vorefamily.net/thewoodenradio <-The weblog
Jul 16 '05 #4
Mike,

Regarding my Email address, I got so much spam when I posted my Email
address on this forum so I decided not to. Besides, I can't see the
relevancy of my Email to this at all.

Now, what you suggest will choose all the records with the date July/03.
What I need is not to have them selected by the date but grouped by a
certain date. I will give you an example. Suppose I have a 'date' field and
a 'sum' field. What I need is a report about the total sum in each month.
And I wonder what is the most simple way to do it.

Regards,
Albert Ahtenberg

"Mike Vore" <mv***@ix.netcom.cam> wrote in message
news:sl******************@snowmass.mystic.ct...

First get a real email address if you want real replies.

On Fri, 27 Jun 2003 20:54:25 -0400, Albert <do**********@this.address>

wrote:
It is the MySql DATE type. looks like (DD-MM-YYYY).

^^^^^^^^^^
This isn't a MySQL date format.
select * from mydatabase where datefield like "2003-07%";

This works for me.


"Steven James Samuel Stapleton" <st**********@mps.ohio-state.edu> wrote in message news:mcgHx12drhfu@ohstpy...
What format is the date field stored in?

Is there a day, month, and year field (separate)?
Is it a timestamp?
Is it something else?

-Jim Stapleton

"Albert Ahtenberg" <do**********@this.address> wrote in message
news:bd**********@tabloid.uwaterloo.ca...
> Hi,
>
> I have a database with a date field. And I would like to see the report > grouped by a ceratin month and year, how can I do that without multiple > queries?
>
> Albert Ahtenberg
>
>


--
Michael Vore, W3CCV M-ASA [Ka8]; WHIRL, ABC; CAW, CW, AAW
http://mike.vorefamily.net/ohmywoodness <-Custom Woodworking
http://mike.vorefamily.net/thewoodenradio <-The weblog

Jul 16 '05 #5
Albert Ahtenberg wrote:
select * from mydatabase where datefield like "2003-07%";


maybe
select year(datefield), month(datefield), sum(valuefield)
from table
group by year(datefield), month(datefield)

HTH

--
"Yes, I'm positive."
"Are you sure?"
"Help, somebody has stolen one of my electrons!"
Two atoms are talking:
Jul 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Lenz Grimmer | last post: by
reply views Thread by Mike Chirico | last post: by
3 posts views Thread by Juan Antonio Villa | last post: by
1 post views Thread by Ike | last post: by
3 posts views Thread by Me Alone | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.