[kornshell] Getting the next weekday date


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [kornshell] Getting the next weekday date
# 1  
Old 08-09-2005
[kornshell] Getting the next weekday date

Hi All

can anyone help me with this, Im new to kornshell scripting and is trying to get the next weekday to a variable:

strDate=%date '+%Y%m%d' // YYYYMMDD

strNewDate= Smilie

// assuming that current date is 20050812 (friday) then strNewDate will get 20050815 (monday) or if current date if 20050811 (thursday) then strNewDate will get 20050812 (friday)

I know I could get the day separately and then add 1, but I would also need to verify the number of days in the month so as not to exceed the months number of days; and verify if this would be a weekday; which would require a pretty long function

Thanks
# 2  
Old 08-10-2005
First, I suggest you look at Perderabo's datecalc - it will probably be very useful to you.

Second, as far as working on which day it is and which day is next, suggest you look at date +%w which will give you the number of the day in the week (0=Sunday, 1=Monday,...) and you can easily figure out which day you need to go to next. This along with calling datecalc should solve all your issues.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[ksh] Weekday a week ago

Hi, Using TZ and date gives an easy way to find out the dates one or more days ago. Now I am in need of knowing the date one week ago. So, now is Thursday and I want to know the date on Thursday a week ago. Unfortunately I can only get as far back as 6 days ago When using TZ+168 it reverts... (7 Replies)
Discussion started by: ejdv
7 Replies

2. Shell Programming and Scripting

yesterday's "weekday" date

i've been going through https://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html to find a cmd that will print me yesterday's date. I have found one that does it nicely set YEST = `date '+20%y/%m/%d' | awk -F"/" '{print $1$2($3-1)}'` as you can... (3 Replies)
Discussion started by: jack.bauer
3 Replies

3. Shell Programming and Scripting

Writing a script to run weekly/monthly - check for weekday or day-of-the-month

Hi all, I currently have a UNIX file maintenance script that runs daily as a cron job. Now I want to change the script and create functions/sub inside it that runs on a weekly or monthly basis. To run all the scripts' daily maintenance, I want to schedule it in cron as simply maint.sh... (1 Reply)
Discussion started by: newbie_01
1 Replies

4. Shell Programming and Scripting

get weekday based on date

Hi all, i am looking for a method of determining the weekday when date is know (bash, if possible). Let's say that i am looking to get the weekday for MAY 01 2011, how can i convert this into Sunday or SUN? any suggestions? (4 Replies)
Discussion started by: gigagigosu
4 Replies

5. Shell Programming and Scripting

Help with Kornshell Script

Hi, I'm a novice at programming and need some help with a kornshell script I've been writting. I have an inputdirectory with all my .shp files. In my input directory the shapefiles are named XXXX_original.shp, XXXX_UPDATE.shp ect. In my .ksh script I have created a for loop which... (2 Replies)
Discussion started by: beery
2 Replies

6. Shell Programming and Scripting

How to get the weekday of the given date?

Hi All, Thanks in Advance. I want a function/script which returns the weekday of the given date. the input to the function/script is the date with format MM/DD/YYYY, it should return the weekday as 1 for sunday, 2 for monday .......7 for saturday. ex: if the function called like this ... (14 Replies)
Discussion started by: rinku11
14 Replies

7. Shell Programming and Scripting

help with Kornshell function

I am trying to write a Kornshell function that takes a string parameter which represents a filename or directory name. The function checks to see if there are any spaces in the filename or directory name and then replaces the spaces with an underscore. The returned value is a filename or directory... (1 Reply)
Discussion started by: ckrieger1
1 Replies

8. Shell Programming and Scripting

Need Help with KornShell script

I need a KornShell script that will, among all the users currently logged on to the system, find a slot of one hour that contains the most number of users. I know how to list all the users currently logged on but how do I do anything with the times that are listed? Please help, thanks. (1 Reply)
Discussion started by: ckrieger1
1 Replies

9. Programming

Kornshell convdate

Hello, I'm currently doing some programming using the Kornshell environment. I have just been on a Unix course where our instructor gave us some coding examples. I am using one of these examples to solve a few problems. However, the code examples use a function called 'convdate' to convert a... (10 Replies)
Discussion started by: nezster
10 Replies

10. UNIX for Dummies Questions & Answers

Kornshell 93

I've been asked to upgrade from Kornshell 88 to Kornshell 93 on a Solaris 7 box. Since my experience with Unix is limited can anyone point me in the right direction? Specifically, where can I get the files that I need to do the upgrade? Thanks. (1 Reply)
Discussion started by: Ask Me
1 Replies
Login or Register to Ask a Question