Re: Work hours?

From: Uwe Seher <uwe(dot)seher(at)gmail(dot)com>
To: stan <stanb(at)panix(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Work hours?
Date: 2019-08-28 11:50:53
Message-ID: CADtXaagu=juUox7YO3N2Gd-uCp4iiPnaiDQeuZ74iB1-8FV5Ow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

*select sum(case when extract(dow from t.d) in (1,2,3,4,5) then 1 else 0
end) * 8 as hours*
* from generate_series(current_date::date, (current_date + '10
days'::interval), '1 day'::interval) as t(d)*

*This calculates the working days/hours between 2 dates. You can make your
firt/lastr day of the month/year to a date and feed it into the series.*

*Bye Uwe*

Am Mi., 28. Aug. 2019 um 00:27 Uhr schrieb stan <stanb(at)panix(dot)com>:

> I am just starting to explore the power of PostgreSQL's time and date
> functionality. I must say they seem very powerful.
>
> I need to write a function that, given a month, and a year as input returns
> the "work hours" in that month. In other words something like
>
> 8 * the count of all days in the range Monday to Friday) within that
> calendar month.
>
> Any thoughts as to the best way to approach this?
>
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message francis picabia 2019-08-28 12:36:39 How to log 'user time' in postgres logs
Previous Message Luca Ferrari 2019-08-28 10:45:56 Re: Work hours?