Hi John,

further research indicates that for PG I could trysomething like:

SELECT EXTRACT(MONTH FROM TIMESTAMP) 

Big John has offered some advice using:

 $today = getdate();
 $start = $today['year'] . '-' . $today['mon'] . '-' . '01';
 $end  =  $today['year'] . '-' . $today['mon'] . '-' . '31';

"SELECT * FROM guest WHERE pdate BETWEEN {$start} AND {$end}";

but PG doesn't like my format of $pdate as type date, since the result for 
$start and $end seems to result in type integer. Sigh.

What a pain. Such a simple task, and  . . .

Thanks for your advice. I'll keep hacking away at it, and maybe I'll get it 
to work.

Regards,
Andre




On Tuesday 23 July 2002 09:52 pm, you wrote:
> Isn't there a MONTH function in PG?
>
> SELECT * FROM your_table WHERE MONTH(NOW()) = MONTH(your_column) ??
>
> Or if PG stores dates in the Unix timestamp format, is the an equivalent
> to date() that you can extract the month from the column and compare
> them??
>
> ---John Holmes...
>
> > -----Original Message-----
> > From: Andre Dubuc [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, July 23, 2002 7:26 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] Sorting db entries by Year-Month
> >
> > Apache 1.3.23 + PHP 4.1.2 + PostgreSQl 7.2
> >
> > I have a guestbook that I would like to display the current month's
> > entries.
> > I can display all the entries before the current month, but i can't
>
> seem
>
> > to
> > figure out how to extract the currrent month's.
> >
> > Although the code below is a db issue, I don't know whether I should
>
> write
>
> > code to extract the info before or after the db connection. Should I:
> >
> >     1.  Set up the parameters beforehand in PHP, and then do a
>
> query;
>
> >     2.  Within the query itself (as the code I tried [and didn't
>
> work]
>
> > below);
> >     3.  Or, somehow in PHP, after I get all the results [obviously
> > without the
> >             db WHERE clause].
> >
> > <?php
> > // lots of code
> >
> > $db = pg_connect("dbname=rap user=postgres");
> > $query = "SELECT * FROM guest WHERE pdate = "{$_SESSION['pdate'] ==
> > date('Y-m')";  // pdate is formatted ('Y-m-d')
> >
> > // etc, etc. . .
> > ?>
> >
> > I know this is a simple question -- but my mind's totally blotto after
>
> a
>
> > day's coding.
> >
> > Any help, pointers of where to look, or admonitions will be gratefully
> > accepted.
> >
> > Tia,
> > Andre
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to