RHEL 7.5
BASH GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
In MS Excel, I'm able to use Network days to find no. of days between two dates. Wondering if it's possible using bash as first preference (--or any other pre-installed language on Linux supporting to solve this possibly using a one-liner - my second preference). I'm not sure if there exists any library or custom tool/utility in Linux which calculates this value.
- To calculate the number of workdays between two dates, you can use the NETWORKDAYS function. NETWORKDAYS automatically excludes weekends, and it can optionally exclude a custom list of holidays as well. Note that NETWORKDAYS includes both the start and end dates in the calculation if they are workdays.
I have a file.txt containing 2 column fields in YYYY-mm-dd format for Resolved and Start dates (you can ignore header line for now):
Resolved,StartOfWork
2020-01-16,2020-01-10
2020-01-13,2020-01-13
2020-01-20,2020-01-15
2020-01-20,2020-01-14
2020-01-14,2020-01-09
2020-01-09,2020-01-08
2020-01-16,2020-01-14
2020-01-09,2020-01-07
2020-01-14,2020-01-12
For each row, I want to calculate no. of NETWORK i.e. WEEK DAYS only between these 2 dates (doesn't matter if Resolved/StartOfWork dates were on weekend days: Saturday/Sunday).
- The calculation of no. of days SHOULD NOT include 'weekend-days i.e. Saturday/Sunday in it.
PS: For the purpose of this post, my question is very different than what this post is asking for: How to find the difference in days between two dates?