April 9, 2025 at 5:36 pm
Hello all. Trying to measure the time in days between to dates excluding weekends. Currently I have this but I am nit sure how to use the generate_series command in this code so there are errors.
Select fsono, fcompany, forderdate, confirmdate, confirmed--,
(select Count(*) as daysopen from generate_series(a.confirmdate, a.forderdate -interval '1 day' interval '1 day') theday
where extract('ISODOW' From theday) < 6)
from
(select fsono, fcompany, forderdate, isnull(ftdate, '') as ConfirmDate, isnull(fmnewval, 'False') as Confirmed,
isnull(cast(ftdate as numeric) - cast(forderdate as numeric),
cast(current_timestamp as numeric) - cast(forderdate as numeric)) as days
from somast
left outer join (select max(ftdate) as ftdate, fcmaster, fmnewval, fcfield from syecaudt
group by fcmaster, fmnewval, fcfield) a on a.fcmaster = fsono and a.fcfield = 'chkshpcnfm' and fmnewval like 'T%'
where upper(fstatus) = 'OPEN' ) a
order by fsono
any and all help appreciated. Thanks
April 9, 2025 at 5:40 pm
Ah I go it. DateDiff(WEEK, a.forderdate, a.confirmdate) *2 as weekdays
April 9, 2025 at 5:42 pm
Now I guess how to deal with holidays that move? HAHHA
April 10, 2025 at 8:01 am
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply