Re: How to specify the beginning of the month in Postgres SQL syntax?

Поиск
Список
Период
Сортировка
От sqllist
Тема Re: How to specify the beginning of the month in Postgres SQL syntax?
Дата
Msg-id 002101c3bede$ed1e29e0$0f32a8c0@denisnew
обсуждение исходный текст
Ответ на How to specify the beginning of the month in Postgres SQL syntax?  (jeff@dnuk.com)
Ответы Re: How to specify the beginning of the month in Postgres SQL syntax?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hi Jeff,

You can use

WHERE date < to_date( to_char(current_date,'yyyy-MM') || '-01','yyyy-mm-dd')

Thanx

Denis


----- Original Message -----
From: <jeff@dnuk.com>
To: <pgsql-sql@postgresql.org>
Sent: Sunday, December 07, 2003 9:46 PM
Subject: [SQL] How to specify the beginning of the month in Postgres SQL
syntax?


> Hello,
>
> I need to create a view in Postgres that has a where clause of the
> date < beginning of month.
>
> i.e.:
> SELECT supplier_number, Sum(amount) AS due
> FROM purchase_orders
> WHERE date < '2003-12-1' AND paid = 0
> GROUP BY supplier_number
> ORDER BY supplier_number ASC
>
>
> As you can see, I've specified the 1st of December this year as the
> where clause. What I want is an SQL statement that automatically
> generates the first of the month. How do I do this?
>
> Thanks.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match



В списке pgsql-sql по дате отправления:

Предыдущее
От: Paul Thomas
Дата:
Сообщение: Re: How to specify the beginning of the month in Postgres SQL syntax?
Следующее
От: Olivier Hubaut
Дата:
Сообщение: Bug in JDBC CREATE FUNCTION syntax?