Re: Get Unix timestamp from SQL timestamp through libpq

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Get Unix timestamp from SQL timestamp through libpq
Дата
Msg-id 80B7B558-F71D-45C5-9EA4-39B7646F0A41@solfertje.student.utwente.nl
обсуждение исходный текст
Ответ на Get Unix timestamp from SQL timestamp through libpq  (Yan Cheng Cheok <yccheok@yahoo.com>)
Список pgsql-general
On 11 Jan 2010, at 7:16, Yan Cheng Cheok wrote:

> I know I can convert SQL timestamp to unix timestamp, using the following way.
>
> SELECT extract(epoch FROM now());
>
> Now, I have a stored procedure function, which will directly return a table row to the caller. One of the row field
is"timestamp" type.  
>
> In my application, I am using libpq. I wish to use libpq functions (or any c/c++ function), to convert "2010-01-11
13:10:55.283"into unix timestamp. 

The format of that "timestamp" you're referring to is dependant on client and server settings (locale among others). If
yougo this way make sure you specify the format when making the connection. 

Another option is to add an extra epoch column to your result-row and return that row instead of the original row.
You'dhave to change the return type to include the extra column of course (see RETURNS TABLE in the docs). 

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,4b4b0e7a10733449211764!



В списке pgsql-general по дате отправления:

Предыдущее
От: Ivan Sergio Borgonovo
Дата:
Сообщение: Re: R: aggregate over tables in different schema
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Get Unix timestamp from SQL timestamp through libpq