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

From Alvaro Herrera
Subject Re: get date in binary number format
Date
Msg-id Pine.LNX.4.44.0209270021040.27017-100000@alvh.no-ip.org
Whole thread Raw
In response to Re: get date in binary number format  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: get date in binary number format
List pgsql-general
Tom Lane dijo:

> Alvaro Herrera <alvherre@atentus.com> writes:
> > Is there a way to cast these bitstrings into varchars or something?  I
> > can't find any.
>
> 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;
            varcharin
----------------------------------
 00000000000000000000000000000001
(1 row)

So going back to Shaunn's question, it's rather confusing to set
everything up (you'll have to use cut'n pasting from this message and my
previous followup), BUT it doesn't work in previous releases (only in
7.3beta).  Maybe you can adapt it, but it's not clear to me that the
casting from bit to varchar is possible in 7.2.

--
Alvaro Herrera (<alvherre[a]atentus.com>)
"La realidad se compone de muchos sueños, todos ellos diferentes,
pero en cierto aspecto, parecidos..." (Yo, hablando de sueños eróticos)


pgsql-general by date:

Previous
From: Joe Conway
Date:
Subject: Re: SQL subquery to supply table name?
Next
From: "Matt Wagner"
Date:
Subject: Quick Pg/PLSQL question