next/Previous business day


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting next/Previous business day
# 1  
Old 08-15-2007
next/Previous business day

Hello,
Can you please help me how do i get previous and next working day of the week for a given date excluding saturday and sunday.

Ex: if the given date is monday, i should get friday and tuesday's date
if the given date is friday, i should get thrusday and monday's date.

Thanks,
Sateesh
# 2  
Old 08-15-2007
Are you open to using datecalc? This will do the job, but you will have to wrap the script in another script of your own.

In your script, just check if day is Friday or Monday. Then accordingly call datecalc with the correct +/- parameters. If not, just call datecalc with +1 and -1 to get tomorrows and yesterday's date. You can check the datecalc script for more help.
# 3  
Old 08-15-2007
All you really need is a couple of arrays with the offsets. I also have started using an array to store dates in y m d format.
Code:
$ set -A Prev -- -2 -3 -1 -1 -1 -1 -1
$ set -A Next 1 1 1 1 1 1 3 2
$ set -A today $(date "+ %Y %m %d")
$ echo ${today[*]}
2007 08 15
$ datecalc -d 1961 1 1
$ datecalc -a ${today[*]} + ${Prev[$(datecalc -d ${today[*]})]}
2007 8 14
$ set -A today 2007 08 13
$ datecalc -a ${today[*]} + ${Prev[$(datecalc -d ${today[*]})]}
2007 8 10
$ cal
    August 2007
 S  M Tu  W Th  F  S
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

$

# 4  
Old 08-23-2007
previous bussiness date

Hello,

I am also having the same problem. I want the previous bussiness date. But If monday comes it should give fridays date. IN the same way if holiday comes in between, it should run the exact previous date. Please help. It is urgent...........
# 5  
Old 10-16-2007
how to get the last week friday date and present week thursday date

help me
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

View file on previous day

Hi Expert, I am new to UNIX , I am looking for a script which can show me list of file created on previous date within specified directory. Regards, Mack (9 Replies)
Discussion started by: mackjack
9 Replies

2. UNIX for Dummies Questions & Answers

List the files of previous day

I am using KSH. d=date | nawk '{ print $2,$3-1}' ls -lrt SystemOut* | nawk '/d/{print $NF}' I am trying to list the files of previous day but it doesn't seem to be working and i am also not getting an error. result is blank.Need help. (11 Replies)
Discussion started by: vagar11
11 Replies

3. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

4. Red Hat

Cron entry for every 10 mints on business day business hour

Could you “crontab” it to run every 10 minutes on work days (Mo - Fr) between 08:00 and 18:00 i know to run every 10 mints but can any one guide me how to achieve the above one (2 Replies)
Discussion started by: venikathir
2 Replies

5. Shell Programming and Scripting

Script to check if last modified day is previous day

Hi, I would like to write a script that checks if a file ('counter') was modified the previous day, if so erase its contents and write 00000000 into it. For e.g. if the file 'counter' was last modified at 11.30pm on 24th May and the script runs at 12.15am of 25th May, it should erase it's... (1 Reply)
Discussion started by: hegdepras
1 Replies

6. Shell Programming and Scripting

how to find the second business day of month

I want to decide is that today is larger than the second business day of this month, who can i find second business day of this month? (3 Replies)
Discussion started by: qjlongs
3 Replies

7. Shell Programming and Scripting

getting previous day.

Hi, i am developing a script for my project. In my script i need to check some conditions based upon some values. in that one value is the previous date. with the previous date i need to check and process some values. I have a function with me retrieve the yesterdays date. But now i have a... (6 Replies)
Discussion started by: intiraju
6 Replies

8. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

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)
Discussion started by: girish.raos
3 Replies

9. Shell Programming and Scripting

Display month for Previous day

Hello - I have one question regarding the date. I wanted to display the month name for previous day. The output should be as follows... 5-Feb-09 => February 1-Feb-09 => January 28-Feb-09=> February Here is the code i am using to get the output.... date '+%m %d %Y' | { read MONTH DAY... (4 Replies)
Discussion started by: govindts
4 Replies

10. Shell Programming and Scripting

Finding out the first business Day of the month

Hi , I want to find out the first business day of the month using korn shell programming.... ie if March 1 is saturday , March 2 is sunday and 3 is monday My code should identify the First business day..as March 3.. hope u got it.. suggestions ??? Pls look into this asap...... (1 Reply)
Discussion started by: phani
1 Replies
Login or Register to Ask a Question