Re: get date in binary number format - Mailing list pgsql-general

From Tom Lane
Subject Re: get date in binary number format
Date
Msg-id 21155.1033101679@sss.pgh.pa.us
Whole thread Raw
In response to Re: get date in binary number format  (Alvaro Herrera <alvherre@atentus.com>)
List pgsql-general
Alvaro Herrera <alvherre@atentus.com> writes:
> Tom Lane dijo:
>> regression=# select ("bit"((date_part('doy', now()))::integer))::text;
>> ERROR:  Cannot cast type bit to text

> Well, there is:

> testing=> select varcharin(bit_out(bitv), 0, length(bitv)+4  )  FROM
> (select "bit"(1) AS bitv) as t;

Oh, of course, I keep forgetting that now that cstring is a first-class
type, all things are possible via abutted I/O function calls ;-)

You could simplify that as

select varcharin(bit_out("bit"(1)), 0, -1);

But either way you must admit that the above is an ugly hack not proper
support.

            regards, tom lane

pgsql-general by date:

Previous
From: "Matt Wagner"
Date:
Subject: Quick Pg/PLSQL question
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Quick Pg/PLSQL question