Skip site navigation (1) Skip section navigation (2)

Re: Weeks elapsed to Months elapsed conversion

From: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
To: "'Allan Kamau'" <allank(at)sanbi(dot)ac(dot)za>,<pgsql-sql(at)postgresql(dot)org>
Subject: Re: Weeks elapsed to Months elapsed conversion
Date: 2008-05-30 16:22:08
Message-ID: 002501c8c271$4e46e0a0$8f01010a@iptel.com.ar (view raw or flat)
Thread:
Lists: pgsql-sql
> 
> 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.


In response to

pgsql-sql by date

Next:From: Rodrigo E. De León PlicetDate: 2008-05-30 17:19:55
Subject: Re: Weeks elapsed to Months elapsed conversion
Previous:From: Richard HuxtonDate: 2008-05-30 15:13:47
Subject: Re: Weeks elapsed to Months elapsed conversion

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group