Re: Work hours?
От | Uwe Seher |
---|---|
Тема | Re: Work hours? |
Дата | |
Msg-id | CADtXaagu=juUox7YO3N2Gd-uCp4iiPnaiDQeuZ74iB1-8FV5Ow@mail.gmail.com обсуждение исходный текст |
Ответ на | Work hours? (stan <stanb@panix.com>) |
Список | 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 по дате отправления: