Hi all!
I think this is a very interesting problem It's closely related to some cron issues one might have.
So I thought about it "logically". If we by the first working day of a month we mean any Monday-Friday (days 1 to 5 in our calendar) that appears as the first day of the month, we have a hit. Not regarding any local holidays or calendars different than what we use here in Europe for example. Then the first work day can only appear as the 1st, 2nd or 3rd day of the month. If today is the first day of the month, and today is a work day, well then it is the first in the month. If today is the second or third day of the month, it can only be the first work day if it is a Monday.
So one way to establish if today is the first working day of the month could be something like this, it may be similar to other solutions presented. And a little bit verbose maybe, just to show the logic of it:
And then the value of $first can be used as true or false, 1=true, anything else is false. (The while construct is a lazy way to get around child vs. parent variable issues)
One way to test it is this little program that chews through dates 600 days into the future (just an example), to establish if it is the first work day in each month, and just compare it with a regular calendar. Etc, etc... :
I use bash. I may have made some spleling errors, but it works on my machine
/L
---------- Post updated at 11:49 PM ---------- Previous update was at 09:41 PM ----------
Oi!
I just realised there was another funny use for this. Not sure if it's very effective to run the date command for every day, but anyway:
Output:
'nuff for now,
Off to bed
/Lakris
Last edited by Lakris; 08-11-2010 at 06:33 PM..
Reason: a twist on the second script... simplyfied if-statement
Hi ,
I am relatively new to unix...
Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell..
This is very urgent.
Thanks for ur help... (7 Replies)
How to find the first day of previous month in unix mmddyyyy format?
example : today is 07052007 (in mmddyyyy)
output sud be 06012007
thanks
mohapatra (10 Replies)
Hi
I need a script to get "Last working day of the month". I will pass the month and year as parameters and i need to get the last working date.
Ex
for June 2008 the last working day is 30th its monday.
for August 2008 the last working day is 29th and it is Friday.
ie the last working... (6 Replies)
Hi,
I want a script(ksh) to see if today is the last working day(Mon-Fri) of the month. If it is the last working day I need to print current date, else I need the last working day of previous month. Thanks in advance. (1 Reply)
Hi All,
I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this.
My Requirment is as below:
Input for me will be 2000909(YYYYMM)
I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Hello All,
I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer.
Any ideas would be appreciated! (5 Replies)
Hello Guys,
I have a questions regarding running a shell script every second working day each month.
I have no clue how solve this problem :wall:.
Important is that it has to be the second working (Mo-Fr).
Example: If 1st and 2nd Days of month are Sat and Sun the script must run on 4th day... (5 Replies)
Hi,
I would like to calculate 1st working/Business day of each month.
Exp:
1st -Oct-2011 is Saturday--- Non Business Day
So the Next Working Day would be 3-Oct-2011
I need a shell script to calculate the month first business date. (3 Replies)
hello,
I have many files called day001, day002, day003 and I want to rename them by day20070101, day20070102, etc.
I need to do it for several years and leap years as well.
What is the best way to do it ?
Thank you. (1 Reply)