Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-resource-management
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-resource-management
Commits
ee562270
Commit
ee562270
authored
May 31, 2018
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Added a workday count based on a formula rather then on an iteration
parent
40c87f36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
intranet-resource-management-create.sql
sql/postgresql/intranet-resource-management-create.sql
+22
-0
No files found.
sql/postgresql/intranet-resource-management-create.sql
View file @
ee562270
...
...
@@ -247,6 +247,27 @@ begin
end
;
$
body
$
LANGUAGE
'plpgsql'
VOLATILE
;
-- Returns just the number of working days between two dates
CREATE
or
REPLACE
FUNCTION
im_resource_mgmt_workday_count
(
date
,
date
)
RETURNS
integer
AS
$
BODY
$
SELECT
(
$
1
<
$
2
)::
int
*
(
to_char
(
$
2
,
'J'
)::
integer
-
to_char
(
$
1
,
'J'
)::
integer
-
(((
$
2
-
$
1
)
/
7
)
*
2
+
(
EXTRACT
(
dow
FROM
$
1
)
<
6
AND
EXTRACT
(
dow
FROM
$
2
)
>
0
AND
EXTRACT
(
dow
FROM
$
1
)
>
EXTRACT
(
dow
FROM
$
2
))::
int
*
2
+
(
EXTRACT
(
dow
FROM
$
1
)
=
6
AND
EXTRACT
(
dow
FROM
$
2
)
>
0
)::
int
+
(
EXTRACT
(
dow
FROM
$
2
)
=
0
AND
EXTRACT
(
dow
FROM
$
1
)
<
6
)::
int
)
);
$
BODY
$
LANGUAGE
'sql'
IMMUTABLE
STRICT
;
select
im_resource_mgmt_workday_count
(
'2018-05-01'
::
date
,
'2018-05-31'
::
date
);
-- Returns the work days for a given period
-- whereas: "work days" = Number of days in period -absences -bank_holidays -weekends
-- Expects start_date and end_date as YYYY/MM/DD
...
...
@@ -277,6 +298,7 @@ end;$body$ LANGUAGE 'plpgsql' VOLATILE;
-- Returns a real[] for each day between start and end
-- with 100 for working days and 0 for weekends
create
or
replace
function
im_resource_mgmt_weekend
(
integer
,
date
,
date
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment