Re: Work hours? - Mailing list pgsql-general

From Uwe Seher
Subject Re: Work hours?
Date
Msg-id CADtXaagu=juUox7YO3N2Gd-uCp4iiPnaiDQeuZ74iB1-8FV5Ow@mail.gmail.com
Whole thread Raw
In response to Work hours?  (stan <stanb@panix.com>)
List 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@panix.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


pgsql-general by date:

Previous
From: Luca Ferrari
Date:
Subject: Re: Work hours?
Next
From: francis picabia
Date:
Subject: How to log 'user time' in postgres logs