On 19-Nov-08, at 8:42 AM, Ken Ramsay wrote:

>
> Thanks guys,
>
> MySQL defines the field as a DATETIME , so the return type is time_t.

No; you are using an expression, not the column, so the result type  
is indeed BIGINT, as Markus surmised (his explanation was correct, as  
far as I can determine).

> As
> far as I could find out, there is no helper funtion to convert this  
> into
> secs from 1 Jan 1970 ,

You indeed get seconds from UNIX epoch, as documented*, if you access  
the returned result field using 'dbi_result_get_longlong_idx()'.

(Or if you want to retrieve by name, I suggest using an alias for  
maintainability/readability's sake.)

--Toby

* - http://dev.mysql.com/doc/refman/5.0/en/date-and-time- 
functions.html#function_unix-timestamp


> so I got around it by using the difftime() call
> and subtracting the returned value from 1/1/1970. difftime()  
> returns the
> difference in seconds.
>
> Not sure it is the most elegant way to do it but it works ...;-}
>
> Cheers
>
>
>
> -----Original Message-----
> From: Markus Hoenicka [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 18, 2008 5:38 PM
> To: Ken Ramsay
> Cc: libdbi-users@lists.sourceforge.net; [EMAIL PROTECTED]
> Subject: [libdbi-users] UNIX Timestamp - DATE to UTC conversion
>
> Ken Ramsay writes:
>>           time = dbi_result_get_uint(result,
>> "UNIX_TIMESTAMP(HIST_Timestamp)");
>
> Without actually trying the code: one rough guess is that MySQL  
> does not
> return the timestamp as an uint value but as something longer. Did you
> try using dbi_result_get_field_type() and
> dbi_result_get_field_attrib() to find out which type is returned?
>
> regards,
> Markus
>
> --
> Markus Hoenicka
> [EMAIL PROTECTED]
> (Spam-protected email: replace the quadrupeds with "mhoenicka")
> http://www.mhoenicka.de
>
>
> This email was sent to you by Thomson Reuters, the global news and  
> information company.
> Any views expressed in this message are those of the individual  
> sender, except where the sender specifically states them to be the  
> views of Thomson Reuters.
>
>
>
> ---------------------------------------------------------------------- 
> ---
> This SF.Net email is sponsored by the Moblin Your Move Developer's  
> challenge
> Build the coolest Linux based applications with Moblin SDK & win  
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in  
> the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> libdbi-users mailing list
> libdbi-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libdbi-users


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users

Reply via email to