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

From Johnson, Shaunn
Subject Re: get date in binary number format
Date
Msg-id 73309C2FDD95D11192E60008C7B1D5BB04C73FC3@snt452.corp.bcbsm.com
Whole thread Raw
In response to get date in binary number format  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
Responses Re: get date in binary number format  (Darren Ferguson <darren@crystalballinc.com>)
Re: get date in binary number format  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general

Howdy:

I get this when I try the following select:

[snip]

testdb=> select "bit"((date_part('doy', now()))::integer);
ERROR:  Function 'bit(int4)' does not exist
Unable to identify a function that satisfies the given
argument types
You may need to add explicit typecasts

[/snip]

Is there something that I should know about "bit"?
Is it a pre-defined function (system) or is this
something I don't have in my version of PostgreSQL?

Thanks all!

-X

-----Original Message-----
From: Alvaro Herrera [mailto:alvherre@atentus.com]
Sent: Thursday, September 26, 2002 11:50 AM
To: Johnson, Shaunn
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] get date in binary number format

Johnson, Shaunn dijo:

> Howdy:
>
> Silly question time -
>
> Is there a way to get the date and change
> it into a binary number?

Well, you can get the day of the year in binary:

testing=> select "bit"((date_part('doy', now()))::integer);
               bit
----------------------------------
 00000000000000000000000100001101
(1 row)

> The algorithm to select backup number would be the
> smallest non-zero place in binary representation of
> the backup number (tape).

Recursive definition?  Sorry, I don't understand the algorithm.

--
Alvaro Herrera (<alvherre[a]atentus.com>)
"Ni aun el genio muy grande llegaria muy lejos
si tuviera que sacarlo todo de su propio interior" (Goethe)

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Performance while loading data and indexing
Next
From: Andrew Sullivan
Date:
Subject: Re: unlock / drop table