Re: get date in binary number format

From: Alvaro Herrera <alvherre(at)atentus(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: get date in binary number format
Date: 2002-09-27 04:34:11
Message-ID: Pine.LNX.4.44.0209270021040.27017-100000@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane dijo:

> Alvaro Herrera <alvherre(at)atentus(dot)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)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-09-27 04:41:19 Re: get date in binary number format
Previous Message Joe Conway 2002-09-27 04:16:28 Re: SQL subquery to supply table name?