inside a custom C function how can convert a string (es. '2012-01-10') date into unix timestamp?
I mean is there some C trick to do the job or some casting? or I need to use SQL calling:
SELECT extract(epoch FROM date('2012-01-10'));
is not this a loss of performance?
I've seen an example with
PGtimestamptz ts;
res = PQexef("select now()");
PQgetf(res, 0, "%timestamptz", 0 , &ts);
int epoch = ts.epoch;
I've install libpqtypes but it seems that the example is incomplete and it doesn't work
could someone suggest the best way for this conversion and/or provide e full example using libpqtypes developing a postgresql custom C function?
I use PostgreSQl 9.3 on a Linux box
thanks a lot
Luca
struct tmwith the contents of thePGtimsamptzand use that as an argument for themktime()function, which is part of the standard library. The timezone part can get tricky, if you would like to handle that too.