From: | "Josh Berkus" <josh(at)agliodbs(dot)com> |
---|---|
To: | Michael Klatt <mdklatt(at)ou(dot)edu>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Number of days in a month |
Date: | 2001-12-06 16:59:18 |
Message-ID: | web-521804@davinci.ethosmedia.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | Jason Earl | 2001-12-06 18:35:45 | Re: Storing number '001' ? |
Previous Message | Josh Berkus | 2001-12-06 16:48:22 | Re: Storing number '001' ? |