pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedselect date range?
4+ messages / 4 participants
[nested] [flat]
* select date range?
@ 2003-06-17 02:56 ko <ko@origo.com.tw>
2003-06-17 03:28 ` Re: select date range? Josh Berkus <josh@agliodbs.com>
2003-06-17 03:43 ` Re: select date range? Ramil G. Sagum <ramil@astra.ph>
2003-06-17 12:02 ` Re: select date range? scott.marlowe <scott.marlowe@ihs.com>
0 siblings, 3 replies; 4+ messages in thread
From: ko @ 2003-06-17 02:56 UTC (permalink / raw)
To: pgsql-sql
Hi,
When I use sql statement to select the date range from $_POST value,It doesn't work.
-------------------------------------------
"select * from mydatabase where mydate between '$_POST[start_date]' and '$_POST[end_date]' "
There is no error,but the result is not I want.
ps:
(1)mydate attribute is timestamp
(2)$_POST[start_date] is something like '2003/05/12'
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: select date range?
2003-06-17 02:56 select date range? ko <ko@origo.com.tw>
@ 2003-06-17 03:28 ` Josh Berkus <josh@agliodbs.com>
2 siblings, 0 replies; 4+ messages in thread
From: Josh Berkus @ 2003-06-17 03:28 UTC (permalink / raw)
To: ko <ko@origo.com.tw>; pgsql-sql
Ko,
> (1)mydate attribute is timestamp
> (2)$_POST[start_date] is something like '2003/05/12'
You probably need to re-format the POST date before passing it to the
back-end. For example, my compilation of PostgreSQL would not necessarily
correctly recognize that date format.
Try re-formatting the date to '2003-05-12'
--
Josh Berkus
Aglio Database Solutions
San Francisco
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: select date range?
2003-06-17 02:56 select date range? ko <ko@origo.com.tw>
@ 2003-06-17 03:43 ` Ramil G. Sagum <ramil@astra.ph>
2 siblings, 0 replies; 4+ messages in thread
From: Ramil G. Sagum @ 2003-06-17 03:43 UTC (permalink / raw)
To: pgsql-sql
hmm it should work fine. Remember, the statement
....where mydate between '2003/05/12' and '2003/06/17'
would ONLY return records from '2003/05/12 to 2003/06/16 since your type
is a timestamp. 2003/06/17 actually means 2003/06/17 00:00:00.000000+00.
so a timestamp of 2003/06/17 03:01:10.102022+08 would not be included in
the query.
got it?
ramil
On Tue, 2003-06-17 at 10:56, ko wrote:
> Hi,
>
> When I use sql statement to select the date range from $_POST value,It
> doesn't work.
>
> -------------------------------------------
> "select * from mydatabase where mydate between '$_POST[start_date]'
> and '$_POST[end_date]' "
>
> There is no error,but the result is not I want.
>
> ps:
> (1)mydate attribute is timestamp
> (2)$_POST[start_date] is something like '2003/05/12'
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: select date range?
2003-06-17 02:56 select date range? ko <ko@origo.com.tw>
@ 2003-06-17 12:02 ` scott.marlowe <scott.marlowe@ihs.com>
2 siblings, 0 replies; 4+ messages in thread
From: scott.marlowe @ 2003-06-17 12:02 UTC (permalink / raw)
To: ko <ko@origo.com.tw>; +Cc: pgsql-sql
On Tue, 17 Jun 2003, ko wrote:
> Hi,
>
> When I use sql statement to select the date range from $_POST value,It doesn't work.
>
> -------------------------------------------
> "select * from mydatabase where mydate between '$_POST[start_date]' and '$_POST[end_date]' "
>
> There is no error,but the result is not I want.
>
> ps:
> (1)mydate attribute is timestamp
> (2)$_POST[start_date] is something like '2003/05/12'
You may be having problems with how PHP interprets (or more correctly,
doesn't) arrays inside of strings. the problem is that inside of a string
the autointerpretation of a string won't work for arrays, only simple
scalars.
Change your string to this:
"select * from mydatabase where mydate between '".$_POST[start_date]."' and '".$_POST[end_date]."'"
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-06-17 12:02 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-17 02:56 select date range? ko <ko@origo.com.tw>
2003-06-17 03:28 ` Josh Berkus <josh@agliodbs.com>
2003-06-17 03:43 ` Ramil G. Sagum <ramil@astra.ph>
2003-06-17 12:02 ` scott.marlowe <scott.marlowe@ihs.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox