Couchbase query to calculate difference between dates excluding weekends

Please help me with Couchbase query to calculate difference between dates excluding weekends

Date functions are described here - Date Functions | Couchbase Docs but I don’t see the function that you are looking for.

User defined functions documentation is here User-Defined Functions | Couchbase Docs. and a blog N1QL Now Supports User-Defined Functions

As @mreiche noted, there isn’t a specialised built-in function for custom date-to-date calculation such as this. You can achieve the calculation with, e.g.

SELECT sum(CASE WHEN date_part_str(dr,"dow") IN [0,6] THEN 0 ELSE 1 END)
FROM (date_range_str("2024-01-04","2024-07-29","day")) dr

Or you could calculate it otherwise with the date functions.

HTH.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.