Need to omit time during weekends from age calculations

From: David Gauthier <davegauthierpg(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Need to omit time during weekends from age calculations
Date: 2021-06-07 19:12:20
Message-ID: CAMBRECBCO3toxcCXRNxZqxqyYyNKdu7icy6x_B0Ln7vdD6uyQw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2021-06-07 19:17:35 Re: Need to omit time during weekends from age calculations
Previous Message Dean Gibson (DB Administrator) 2021-06-07 18:53:00 Re: bottom / top posting