Friday, May 30, 2008

Re: [SQL] Weeks elapsed to Months elapsed conversion

>
> Hi all,
> I have a simple question (tried googling but found no
> answers). How do I convert weeks elapsed into months elapsed?
> I have data that contains duration in weeks (without any
> other date values such as year and so on) for example a week
> value of 14 and I would like to convert the 14 weeks to 3
> months (some lose of accuracy expected).
> Expected tests may be:
> 14 weeks yields 3 months.
> 1 weeks yields 0 months.
>

If accuracy isnt a issue probably floor() could suite you:

months=select floor(weeks/4);

Regards,
Fernando.


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

No comments: