From: | c k <shreeseva(dot)learning(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: finding if a period is multiples of a given interval |
Date: | 2013-01-30 13:19:18 |
Message-ID: | CAN2Y=uOSme-iEhbcbf49FK+TXT_bOB6oOskhQ1mmyT9+U2NBQg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks.
After some hacking it solved my problems using
select date_part('days', age('06/01/2010'::date ,'04/01/2010'::date));
Regards,
On Mon, Jan 28, 2013 at 9:32 PM, Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>wrote:
> On 01/28/2013 07:17 AM, c k wrote:
>
>> I know that. I have to check the period (dates entered by user) must be
>> correct and must be perfectly divisible by the interval given. This is a
>> pre-check for the interest calculation.
>>
>> If user enters '01/04/2010' and '15/05/2010' as the dates, and interval
>> as 'month' then, there are 15 days left and if the banking product is
>> set to calculate interest for a complete month only, then calculation
>> can result in wrong interest figures. So I have to check if given period
>> is perfectly divisible by the interval or not.
>>
>
> I changed the dates to match my date_style.
>
> test=> select age('05/15/2010'::date ,'04/01/2010'::date)
> test-> ;
> age
> ---------------
> 1 mon 14 days
> (1 row)
>
> test=> select date_part('days', age('05/15/2010'::date
> ,'04/01/2010'::date));
> date_part
> -----------
> 14
> (1 row)
>
>
> test=> select age('06/01/2010'::date ,'04/01/2010'::date)
> ;
> age
> --------
> 2 mons
> (1 row)
>
> test=> select date_part('days', age('06/01/2010'::date
> ,'04/01/2010'::date));
> date_part
> -----------
> 0
> (1 row)
>
>
>
>> Regards,
>> C P Kulkarni
>>
>>
>>
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)gmail(dot)com
>
From | Date | Subject | |
---|---|---|---|
Next Message | hamann.w | 2013-01-30 13:32:37 | Re: optimize query? |
Previous Message | C. Bensend | 2013-01-30 13:12:26 | Re: pg_Restore |