Hi All,
Can you help me in finding the business dates (Mon-Fri) between two date ranges.. (forget abt holidays in weekdays)
searched and tried a lot but cant figure this. ISs there any special function availble in unix for this
Hi All,
Can you help me in finding the business dates (Mon-Fri) between two date ranges.. (forget abt holidays in weekdays)
searched and tried a lot but cant figure this. ISs there any special function availble in unix for this
What version of UNIX do you have: uname -a
will tell you.
I am guessing: you are coding in shell - which one?
These answers will help us hlp you.
A question i really like:
What have you tried so far by yourself?
Are you really talking of two date ranges or one range between two limits?
yes, im using Linux 2.6.32-431.29.2.el6.x86_64
trying to get this in bash script.
tried so many commands,
echo $(($(($(date -d "20150511" "+%s") - $(date -d "20150411" "+%s"))) / 86400))
this gives only the day difference
cal | cut -c 4-17
this give only the dates between mon-friday.
I want to get all the business dates between some limit. so i will pass my start date and end date in my script.
And want to get all the BUSINESS DATES (not days) within the specified range so i need to perform some operation on these dates.
With datfile containing
20150411
20150511
, try
date -fdatfil +"%s %u" | { read T2 D2; read T1 D1; echo $(((T1 - T2) * 5 / (86400 * 7) + ((D1 - D2)>0?2:0) )) ; }
21
This is a coarse approxiation and NOT thoroughly tested but for just a handful of ranges, and it has difficulties when the range limits fall into weekends, but it gets pretty close and puts you into a position to optimize.