Re: Need to omit time during weekends from age calculations

From: David Gauthier <davegauthierpg(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Need to omit time during weekends from age calculations
Date: 2021-06-07 21:01:23
Message-ID: CAMBRECBo9iVmKxN-7S-J4ORDdHr2Pswq-0LQYP4Cx3NcOpUfQg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>You seem to be asking about counting work days.
Ya, counting work days, or discounting non-work days. Two sides, same coin.

Thanks Joe. I think the nonweekendhours solution should be good enough for
what I need.

Yes, holidays too would be the best. But for practical purposes, excluding
Sat&Sun is good enough for this particular problem.

Thanks Everyone !

On Mon, Jun 7, 2021 at 3:46 PM Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:

>
>
> po 7. 6. 2021 v 21:17 odesílatel Ron <ronljohnsonjr(at)gmail(dot)com> napsal:
>
>> On 6/7/21 2:12 PM, David Gauthier wrote:
>>
>> Hi:
>>
>> I suspect I'm not the first to ask about this but couldn't find anything
>> after googling for a bit. So here goes....
>>
>> I'd like to get the "age" difference between two times which span either
>> all or part of a weekend but exclude any time that transpired during the
>> weekend.
>> Example (please pardon the non-timestamp vals here...)
>>
>> age('Monday-Noon','Prev-Friday-Noon')
>> would give me '1 day'.
>>
>> ...and...
>>
>> age('Sunday-Noon','Prev-Friday-Noon')
>> would give me '12 hours'
>>
>> You get the picture.
>>
>> Has this wheel already been invented ?
>> I don't see an easy way to do this off-hand.
>> All Ears :-)
>>
>> Thanks in Advance.
>>
>>
>> You seem to be asking about counting work days. Am I misunderstanding?
>>
>
> orafce has functions for business calendar with holidays
>
> https://github.com/orafce/orafce
>
> plvdate.add_bizdays(day date, days int) date
>
> Regards
>
> Pavel
>
>
>> --
>> Angular momentum makes the world go 'round.
>>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2021-06-07 21:26:41 Re: Database issues when adding GUI
Previous Message Pavel Stehule 2021-06-07 19:45:38 Re: Need to omit time during weekends from age calculations