Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS returned data lenght????

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Craig Davison <cd AT securityfocus.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS returned data lenght????
  • Date: Wed, 15 Oct 2003 17:33:27 -0600

On Thu, Oct 16, 2003 at 12:34:10AM +0200, Ole Hansen wrote:
> Sorry for the interruption :)
> I an application I do the following when calculating the time as I want
> the time to be represented as UNIX-time used in my application:
>
> DATETIME:
> -------------
> double time;
> u_int32_t days = *((u_int32_t *)value);
> u_int32_t msec = *((u_int32_t *)(value+sizeof(u_int32_t)));
> time = ((double)(days-25567))*24*60*60 + ((double)msec)/1000.0;
>
> The day calculated gives me the expected day but the usec doesnt match.
> This is for CS_DATETIME_TYPE. The calculated value is 8-10 hours behind.

Sort of off-topic, but why not solve this with a query using datediff. An
example using getdate():

SELECT DATEDIFF (SECOND, '1970-01-01', GETDATE()),
DATEPART (MILLISECOND, GETDATE())

Will return the UNIX date (seconds since the epoch) and millisecond part
without mucking around with arithmetic in your code...

--
Craig Davison
Symantec Corporation
+1 (403) 261-5434




Archive powered by MHonArc 2.6.24.

Top of Page