The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
getting previous filename shary Shell Programming and Scripting 3 03-20-2008 05:50 AM
Previous Command vskr72 UNIX for Advanced & Expert Users 0 04-19-2007 07:51 PM
Seeing previous command JackieChan UNIX for Dummies Questions & Answers 4 06-02-2006 10:35 AM
getting the previous command luft UNIX for Dummies Questions & Answers 5 08-18-2005 12:02 PM
Value of previous row using awk videsh77 Shell Programming and Scripting 2 02-18-2005 01:23 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-15-2007
kotasateesh kotasateesh is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 39
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 (permalink)  
Old 08-15-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 08-15-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,123
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 (permalink)  
Old 08-23-2007
london2001 london2001 is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 1
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 (permalink)  
Old 10-16-2007
pujari pujari is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 1
how to get the last week friday date and present week thursday date

help me
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0