Re: Number of days in a month

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Number of days in a month
Дата
Msg-id web-521804@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на Number of days in a month  (Michael Klatt <mdklatt@ou.edu>)
Список pgsql-novice
Michael,

> Is there a PostgreSQL function to return the number of days in a
> month?

No.  You could fairly easily write a SQL function to do this, though.
The function should do the following:

1. Accept a year and month as input.
2. Create a DATETIME value that is the 1st day of that year and month
3. Add one month to the datetime value.
4. Subtract one day from the datetime value
5. Extract the day of the month from that datetime value.
6. The day of the month is your number of days.

For the tools to do this, see:
http://www.postgresql.org/idocs/index.php?functions-datetime.html
and
http://techdocs.postgresql.org/techdocs/faqdatesintervals.php

-Josh Berkus



______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

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

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: Storing number '001' ?
Следующее
От: Jason Earl
Дата:
Сообщение: Re: Storing number '001' ?