Search Postgresql Archives

Re: Work hours?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>:
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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux