Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Table Transformer - Working Days Except Public Holidays

Craig Buchanan March 2, 2021

Hi,

I am trying to get an example working from the Stiltsoft website working and can't get it to work to save myself. The SQL is to calculate the number of working days between two dates less public holidays.

The location of the exact use case on the website can be found: https://docs.stiltsoft.com/display/public/TFAC/Custom+Transformation+-+use+cases+with+advanced+SQL+queries

However when I try and recreate this below is the result I get:

Capture.PNG

SQL Query:

SELECT *,
'Days' - 2 * (('Days' / 7)::integer) -
CASE
WHEN 'Days' % 7 = 0 THEN 0
WHEN 'Start date'::Date->getDay() = 0 THEN 1
WHEN 'Start date'::Date->getDay() + 'Days' % 7 = 6 THEN 1
WHEN 'Start date'::Date->getDay() + 'Days' % 7 > 6 THEN 2
ELSE 0
END
-
(SELECT COUNT(*) FROM
(SELECT *,'Holiday'::Date->getDay() AS 'Day' FROM T2)
WHERE 'Holiday' >= TT.'Start date' AND 'Holiday' <= TT.'End date'
AND 'Day' > 0 AND 'Day' < 6)
AS 'Work days'
FROM
(SELECT *, ('End date' - 'Start date') / "1d" + 1 AS 'Days' FROM T1) AS TT

Result:

Capture.PNG

This is obviously incorrect 

 

1 answer

2 votes
Katerina Kovriga {Stiltsoft}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 2, 2021

Hi @Craig Buchanan ,

You need to set your worklog settings as following to make the query work properly:

Tue 2-1.png

Tue 2-2.png

Tue2-3.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events