pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedany way to convert date via libpq?
4+ messages / 2 participants
[nested] [flat]
* any way to convert date via libpq?
@ 2009-03-11 02:43 Tena Sakai <tsakai@gallo.ucsf.edu>
0 siblings, 1 reply; 4+ messages in thread
From: Tena Sakai @ 2009-03-11 02:43 UTC (permalink / raw)
To: pgsql-admin
Hi Everybody,
I have a C program to read a postgres table. One of
the columns of this table is defined as:
timestamp without time zone
Is there any routine/function that I can use to convert
this field/column value into unix/linux style date for
comparison purpose?
Thank you.
Regards,
Tena Sakai
tsakai@gallo.ucsf.edu
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: any way to convert date via libpq?
@ 2009-03-11 04:55 Scott Marlowe <scott.marlowe@gmail.com>
parent: Tena Sakai <tsakai@gallo.ucsf.edu>
0 siblings, 1 reply; 4+ messages in thread
From: Scott Marlowe @ 2009-03-11 04:55 UTC (permalink / raw)
To: Tena Sakai <tsakai@gallo.ucsf.edu>; +Cc: pgsql-admin
On Tue, Mar 10, 2009 at 8:43 PM, Tena Sakai <tsakai@gallo.ucsf.edu> wrote:
> Hi Everybody,
>
> I have a C program to read a postgres table. One of
> the columns of this table is defined as:
>
> timestamp without time zone
>
> Is there any routine/function that I can use to convert
> this field/column value into unix/linux style date for
> comparison purpose?
select extract('epoch' from timestampfield) ;
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: any way to convert date via libpq?
@ 2009-03-11 06:07 Tena Sakai <tsakai@gallo.ucsf.edu>
parent: Scott Marlowe <scott.marlowe@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tena Sakai @ 2009-03-11 06:07 UTC (permalink / raw)
To: Scott Marlowe <scott.marlowe@gmail.com>; +Cc: pgsql-admin
Hi Scott,
Many thanks for your reply.
I just tried:
select extract (epoch from timestamp with time zone '2008-04-04 20:00:0.0');
and got:
1207364400
which is great!
I suppose there is no problem running this query
via PGexec() in a C program? Something like:
result = PGexec (conn, "FETCH ALL from somePort");
Many thanks.
Regards,
Tena Sakai
tsakai@gallo.ucsf.edu
-----Original Message-----
From: Scott Marlowe [mailto:scott.marlowe@gmail.com]
Sent: Tue 3/10/2009 9:55 PM
To: Tena Sakai
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] any way to convert date via libpq?
On Tue, Mar 10, 2009 at 8:43 PM, Tena Sakai <tsakai@gallo.ucsf.edu> wrote:
> Hi Everybody,
>
> I have a C program to read a postgres table. One of
> the columns of this table is defined as:
>
> timestamp without time zone
>
> Is there any routine/function that I can use to convert
> this field/column value into unix/linux style date for
> comparison purpose?
select extract('epoch' from timestampfield) ;
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: any way to convert date via libpq?
@ 2009-03-11 06:15 Scott Marlowe <scott.marlowe@gmail.com>
parent: Tena Sakai <tsakai@gallo.ucsf.edu>
0 siblings, 0 replies; 4+ messages in thread
From: Scott Marlowe @ 2009-03-11 06:15 UTC (permalink / raw)
To: Tena Sakai <tsakai@gallo.ucsf.edu>; +Cc: pgsql-admin
On Wed, Mar 11, 2009 at 12:07 AM, Tena Sakai <tsakai@gallo.ucsf.edu> wrote:
> Hi Scott,
>
> Many thanks for your reply.
> I just tried:
> select extract (epoch from timestamp with time zone '2008-04-04
> 20:00:0.0');
> and got:
> 1207364400
> which is great!
>
> I suppose there is no problem running this query
> via PGexec() in a C program? Something like:
> result = PGexec (conn, "FETCH ALL from somePort");
It's definitely accessable by anything connecting to the db. Not sure
how that's done in C so someone else will have to chip in on that.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2009-03-11 06:15 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-03-11 02:43 any way to convert date via libpq? Tena Sakai <tsakai@gallo.ucsf.edu>
2009-03-11 04:55 ` Scott Marlowe <scott.marlowe@gmail.com>
2009-03-11 06:07 ` Tena Sakai <tsakai@gallo.ucsf.edu>
2009-03-11 06:15 ` Scott Marlowe <scott.marlowe@gmail.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