Re: Converting a TimestampTz into a C# DateTime

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "'valeriof *EXTERN*'" <valerio_farruggio(at)hotmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Converting a TimestampTz into a C# DateTime
Date: 2016-11-14 12:12:07
Message-ID: A737B7A37273E048B164557ADEF4A58B5397CB41@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

valeriof wrote:
> I'm handling a TimestampTz value inside a plugin to stream WAL changes to a
> .NET client application. What I'm trying to do is to return all possible
> column changes as binary (don't like to have Postgres handle the conversion
> to string as I may need to have access to the bytes at the client level). In
> case of a TimestampTz, is it possible to return the 8-bytes long integer and
> then from the C# application convert the value to Ticks?

Sure, if you know how it is stored internally.

One of your problems will be that the format depends on whether PostgreSQL
was configured with --disable-integer-datetimes or not.

With that switch, a timestamp is a double precision value, otherwise a
64-bit integer value. In the former case, it measures seconds after
midnight 2000-01-01, while in the latter case it measures microseconds
after that timestamp.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-11-14 14:58:44 Re: Syncing Data of data type BLOB into Postgres- Bytea
Previous Message valeriof 2016-11-14 11:52:14 Converting a TimestampTz into a C# DateTime