[pgsql-jp: 37273] Re: 日付型の問い合わせ

川上 雅志 masashi.kawakami @ jcom.home.ne.jp
2006年 6月 22日 (木) 00:01:07 JST


川上です。

> 日付型のフィールドに問い合わせをするときは、シングルクォーテーションでく
> くらないといけないのですが、これを付けずに問い合わせをかけるとエラーでは
> なく、該当0件で結果が返ってきます。
> my_db=> select * from test where birthday = 1990-5-12;
>  no | name | birthday
> ----+------+----------
> (0 rows)
「1990-5-12」を「1990引く5引く12(=1973)」
と解釈してるんじゃないでしょうか?

select * from test where birthday > 1990-5-12;
と実行したら
 no |    name    |  birthday
----+------------+------------
 11 | my name is | 1990-05-12
(1 row)
が返りますよ?

insert into test (no, name, birthday) values (12, 'your name
is','1991/5/12');

を実行してから
select * from test where birthday > 2008-5-12;
を実行すると
 no |    name      |  birthday
----+--------------+------------
 12 | your name is | 1991-05-12

が返りますから。

--
dbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdb
川上 雅志 masashi.kawakami @ jcom.home.ne.jp
qpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqp




pgsql-jp メーリングリストの案内