Re: selecting records by timestamp (date)

From: "Jason Minion" <jason(dot)minion(at)sigler(dot)com>
To: "Rodrigo Llanos" <rodrigollanos(at)gmail(dot)com>, <pgsql-php(at)postgresql(dot)org>
Subject: Re: selecting records by timestamp (date)
Date: 2006-02-28 20:32:18
Message-ID: 261CF9EEB14F5442894AB6DDA93AA6F40758C9@mail.siglercompanies.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Would probably be best to change the input data the user is entering
(seems to be a webpage yes?) to the format YYYY-MM-DD, and don't cast
the timestamp value in the where clause. Also, note that your create
table statement lists your table name as "ValueLog" - try and make sure
that you aren't having case problems. You may need to enclose the table
name in double quotes to keep the case on the query. Also, with your
test query where you are selecing just that field, take the table name
off of the field, and also try and run a "SELECT COUNT(*) FROM ValueLog"
to make sure that you have records to return.

Beware also that you aren't connecting to a separate server that has the
schema but no data on your connection where you are issuing the query.

Jason Minion

________________________________

From: pgsql-php-owner(at)postgresql(dot)org
[mailto:pgsql-php-owner(at)postgresql(dot)org] On Behalf Of Rodrigo Llanos
Sent: Tuesday, February 28, 2006 1:51 PM
To: pgsql-php(at)postgresql(dot)org
Subject: Re: [PHP] selecting records by timestamp (date)

maybe the postgres version in the server is different

On 2/28/06, Jovan Kostovski <chom_devel(at)yahoo(dot)com> wrote:

Hi,

I have the following table running on postgres 8.04:

CREATE TABLE ValueLog
(
idValueLog int4 NOT NULL DEFAULT nextval
('public.idValueLog_seq'::text),
PPx integer,
iValue integer DEFAULT -1,
fValue real DEFAULT -1,
t_tag timestamp without time zone,
t_arr timestamp without time zone,
cot integer,
ack boolean,
blk boolean,
qd_iv boolean,
qd_nt boolean,
qd_sb boolean,
qd_bl boolean,
qd_ov boolean,
CONSTR AINT idValueLog PRIMARY KEY (idValueLog)
)
WITHOUT OIDS;
ALTER TABLE ValueLog OWNER TO $admin_user;"

I've created the following SQL statement to select the records
newer then a given date:

select almvalue.almname , ppoint.ppdimstr, valuelog.ack,
valuelog.blk, to_char(valuelog.t_arr,'DD.MM.YYYY HH24:MI:SS') from
ppoint, valuelog, almvalue where ppoint.ppx = valuelog.ppx and
almvalue.almvalue = valuelog.ivalue and valuelog.ppx = $db_ppx and
to_char(valuelog.t_arr,'YYYYMMDD') >= '$ts

$ts is a string, the date value input by the user and formated
YYYYMMDD

I've developed the web site on my Ubuntu box, but when I
uploaded the site on the server Fedora Core 3, I had problems with the
date filtering. Running psql on the server I've noticed that there were
more data in the select * from value log results, field t_arr something
like MM-DD-YYYY-dsfsdfd (something else which I don't know what it is)
I think that the local time settings on the server makes me the
troubles.

What's the solution?

I've even checked the result of:
select to_char( valuelog.t_arr,'DD.MM.YYYY HH24:MI:SS') from
valuelog;

but instead of data I got empty data set. Why?

What's the best way to do filtering (selecting) data by time?

TIA, Jovan


________________________________

Yahoo! Mail
Bring photos to life! New PhotoMail
<http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=39174/*http://photomail
.mail.yahoo.com> makes sharing a breeze.

--
Atte. Rodrigo A. Llanos N.

Saludos.

Browse pgsql-php by date

  From Date Subject
Next Message Stuart 2006-03-05 01:21:32 Apache 2.2 w/ PHP 5.1.2 and PostGreSQL 8.1
Previous Message Rodrigo Llanos 2006-02-28 19:51:01 Re: selecting records by timestamp (date)