pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kachun Lee <kachun@pathlink.com>
To: Colin Dick <cdick@mail.ocis.net>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Date fields and libpq....
Date: Fri, 26 Jun 1998 15:05:40 -0700
Message-ID: <3.0.1.32.19980626150540.006ab3dc@rr.pathlink.com> (raw)
In-Reply-To: <Pine.LNX.3.96.980626140758.20477B-100000@ocis.ocis.net>
References: <3.0.1.32.19980626134257.006b5b70@rr.pathlink.com>

At 02:17 PM 6/26/98 -0700, you wrote:
>> I think you may want to change your query to:
>> 
>>    select date_part(datetime(abst_att), 'epoch') ....
>> 
>> In addition, unless you were using BINARY cursor, you will need to do
>> something like:
>> 
>>   time_t t = atol(PQgetvalue(res, i, 0));
>
>I have tried this but don't think I understand the internal datetime
>function correctly.  Should my query be(start is defined as abstime):
>
>select start(datetime(abst_att),'epoch') from timebase;

It should be:

  select date_part(datetime(start),'epoch') from timebase;

This means:

  datetime(start)     	     - change start to datetime.
                        		actually, date_part may be able to take
					abstime... I am just not sure.
  date_part(datetime(start), 'epoch')
			  	     - change datetime(start) as epoch,
					i.e. number of sec since 1970/1/1

>And then should this work:
>
>printf("%lu\n",(unsigned long)PGgetvalue(res,0,0));

You would do:

   printf("%s\n", PGgetvalue(res,0,0));

PGgetvalue will return the number of seconds in *string* form. If your
start is around now, the printf should print something like "898898516".
That is why you need to convert it to time_t by something like atol.

>Thanks for your help.
>
>--
>Colin Dick
>On Call Internet Services
>cdick@mail.ocis.net
>
>



view thread (7+ messages)  latest in thread

Message-ID: <3.0.1.32.19980626150540.006ab3dc@rr.pathlink.com>
Permalink:  ../3.0.1.32.19980626150540.006ab3dc@rr.pathlink.com/
Also on:    postgresql.org/message-id/3.0.1.32.19980626150540.006ab3dc@rr.pathlink.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: kachun@pathlink.com, cdick@mail.ocis.net
  Subject: Re: [SQL] Date fields and libpq....
  In-Reply-To: <3.0.1.32.19980626150540.006ab3dc@rr.pathlink.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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