From ko@origo.com.tw Tue Jun 17 02:56:35 2003 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id CB54630F005 for ; Tue, 17 Jun 2003 02:56:35 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 11352-07 for ; Mon, 16 Jun 2003 23:56:25 -0300 (ADT) Received: from mail.origo.com.tw (dns.origo.com.tw [218.32.202.201]) by svr1.postgresql.org (Postfix) with ESMTP id BCE0830F008 for ; Mon, 16 Jun 2003 23:56:23 -0300 (ADT) Received: from myko (unknown [172.28.100.201]) by mail.origo.com.tw (Postfix) with SMTP id A57507E26 for ; Tue, 17 Jun 2003 10:45:43 +0800 (CST) Message-ID: <02c101c3347c$1279d830$c9641cac@myko> From: "ko" To: Subject: select date range? Date: Tue, 17 Jun 2003 10:56:38 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_02BE_01C334BF.2084AE30" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4922.1500 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Spam-Status: No, hits=0.4 tagged_above=0.0 required=5.0 tests=HTML_40_50 X-Spam-Level: X-Archive-Number: 200306/167 X-Sequence-Number: 13925 This is a multi-part message in MIME format. ------=_NextPart_000_02BE_01C334BF.2084AE30 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable Hi, When I use sql statement to select the date range from $_POST value,It does= n'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' ------=_NextPart_000_02BE_01C334BF.2084AE30 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable
Hi,
 
When I use sql statement to select the date range= from=20 $_POST value,It doesn't work.
 
-------------------------------------------
"select * from mydatabase where mydate between=20 '$_POST[start_date]' and '$_POST[end_date]' "
 
There is no error,but the result is not I=20 want.
 
ps:
(1)mydate attribute is timestamp
(2)$_POST[start_date] is something like=20 '2003/05/12'
 
------=_NextPart_000_02BE_01C334BF.2084AE30-- From josh@agliodbs.com Tue Jun 17 03:31:42 2003 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 6DF1530EF9B for ; Tue, 17 Jun 2003 03:31:42 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 12277-09 for ; Tue, 17 Jun 2003 00:31:31 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by svr1.postgresql.org (Postfix) with ESMTP id 6EAEC30EF75 for ; Tue, 17 Jun 2003 00:31:31 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3126938; Mon, 16 Jun 2003 20:31:39 -0700 Content-Type: text/plain; charset="big5" From: Josh Berkus Organization: Aglio Database Solutions To: "ko" , Subject: Re: select date range? Date: Mon, 16 Jun 2003 20:28:46 -0700 User-Agent: KMail/1.4.3 References: <02c101c3347c$1279d830$c9641cac@myko> In-Reply-To: <02c101c3347c$1279d830$c9641cac@myko> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200306162028.46202.josh@agliodbs.com> X-Archive-Number: 200306/168 X-Sequence-Number: 13926 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 From ramil@astra.ph Tue Jun 17 03:37:46 2003 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id C4C5B30EFC2 for ; Tue, 17 Jun 2003 03:37:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 15288-07 for ; Tue, 17 Jun 2003 00:37:36 -0300 (ADT) Received: from sunny1.pacific.net.ph (sunny1.pacific.net.ph [210.23.234.92]) by svr1.postgresql.org (Postfix) with ESMTP id 3437D30EF92 for ; Tue, 17 Jun 2003 00:37:35 -0300 (ADT) Received: from pop2.pacific.net.ph (pop2.pacific.net.ph [210.23.234.90]) by sunny1.pacific.net.ph with ESMTP id h5H3bWpN012514 for ; Tue, 17 Jun 2003 11:37:32 +0800 (PHT) Received: from arwen.hq.astra.ph ([210.23.117.72]) by pop2.pacific.net.ph with ESMTP id h5H3bVY3008828 for ; Tue, 17 Jun 2003 11:37:32 +0800 (PHT) Subject: Re: select date range? From: "Ramil G. Sagum" Reply-To: ramil@astra.ph To: pgsql-sql@postgresql.org In-Reply-To: <02c101c3347c$1279d830$c9641cac@myko> References: <02c101c3347c$1279d830$c9641cac@myko> Content-Type: text/plain Organization: ASTRA Philippines Message-Id: <1055821427.29605.53.camel@arwen.hq.astra.ph> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 17 Jun 2003 11:43:47 +0800 Content-Transfer-Encoding: 7bit X-Archive-Number: 200306/169 X-Sequence-Number: 13927 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' > From scott.marlowe@ihs.com Tue Jun 17 12:04:56 2003 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id CFE5D30F032 for ; Tue, 17 Jun 2003 12:04:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 09719-05 for ; Tue, 17 Jun 2003 09:04:46 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id D48EC30F101 for ; Tue, 17 Jun 2003 09:04:45 -0300 (ADT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h5HC3j4w001610; Tue, 17 Jun 2003 06:03:45 -0600 (MDT) Date: Tue, 17 Jun 2003 06:02:27 -0600 (MDT) From: "scott.marlowe" To: ko Cc: Subject: Re: select date range? In-Reply-To: <02c101c3347c$1279d830$c9641cac@myko> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Archive-Number: 200306/178 X-Sequence-Number: 13936 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]."'"