Get Date of Previous and next Monday


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get Date of Previous and next Monday
# 1  
Old 05-02-2012
Get Date of Previous and next Monday

Hi,

I would like to know how to get Previous Monday and Next Monday from the current date..

thanks
# 2  
Old 05-02-2012
What's your system?
# 3  
Old 05-02-2012
You have a history of vague posts.
Please post your precise Operating System and version and what Shell you are running.
Please also post the reasoning behind this question and what you are trying to achieve. i.e. please give us the problem not the solution.
# 4  
Old 05-03-2012
This is to run Korn Shell in AIX 7

I want to run query for Previous monday to next monday for the given date...
# 5  
Old 05-03-2012
if you have perl and Date::Manip module is installed, then try this

Code:
 
#!/bin/perl
use Date::Manip;
$date = UnixDate(Date_GetPrev("today","mon",0),"%Y-%m-%d");
print $date;
$date = UnixDate(Date_GetNext("today","mon",0),"%Y-%m-%d");
print $date;

# 6  
Old 05-03-2012
ksh93, since version h:
Code:
$ printf "%(%Y-%m-%d)T\n" "last monday" monday
2012-04-30
2012-05-07


Last edited by Scrutinizer; 05-03-2012 at 06:24 AM..
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to get previous date for the given input date..

hi all, need a script or command to get the previous date for the given input date... like in my script i will pass date as input parameter like 2014-12-01 and i want the output as previous date.. ie.. 2014-11-30 (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

2. Shell Programming and Scripting

Date - incorrect results for previous date

Hello: I am bit puzzled with what I could be doing wrong and any help is appreciated. I have a date in YYYMMDD format and I need to find the previous date. Based on the input on this forum, I have come up with the following. It seems to work for all except the following. Here I am passing date... (3 Replies)
Discussion started by: wincrazy
3 Replies

3. Shell Programming and Scripting

Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month: Example: Current date: 20130320 (yyyymmdd) Last date of previous month: 20130228 (yyyymmdd) First date of previous 4th month: 20121101 (yyyymmdd) In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies

4. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

5. UNIX for Dummies Questions & Answers

Can we get every tuesday or monday's date for the current week

Hi Can we get every tuesday or monday's date for the current week ? For the current week i need tuesday's date or monday's date in %m%d%y fromat Thanks (5 Replies)
Discussion started by: laxmi131
5 Replies

6. Shell Programming and Scripting

Pass the first date and last date of previous month

Hi All, I need to run a job every month at the beginning of the month which is scheduled through autosys, lets say on 03/01/2010. I need to pass the last month's i.e February's first_date = 02/01/2010 and last_date = 02/28/2010 as variables to a stored procedure. Can somebody please pass... (2 Replies)
Discussion started by: vigdmab
2 Replies

7. Shell Programming and Scripting

Get the date of monday when running from Friday to next Thursday

Hi, I have a requirement where I want to get the date of monday when I am running the script from previous Friday to the following Thursday. For example: When ever I run the script between 19thFeb2010(Friday) to 25th Feb 2010(Thursday), I should get the date of 22nd Feb 2010 in the format of... (5 Replies)
Discussion started by: fasiazhar_411
5 Replies

8. UNIX for Advanced & Expert Users

Extract Monday from given date

Hi I want to extract the date on Monday depending upon the user input for that week. For example if the input date is 20080528 then the output should be 20080526. If the input is 20080525 then it will be 20080519 i am working on IBM AIX Thanks (2 Replies)
Discussion started by: itsme_maverick
2 Replies

9. UNIX for Dummies Questions & Answers

I wanted to get the date of the first monday of a month.

Hi, I need to display the date of the first monday of a month. Can any one please help me on this. Thanks in advance. (6 Replies)
Discussion started by: Sheethal
6 Replies

10. Shell Programming and Scripting

Specify a previous date as start date in shell script

Hi, I am trying to modify a script which accepts date in format dd/mm/yy. I am trying to modify the script so that it retrieves the date that was 15 days earlier from today as start date. Eg.if today is 05/09/2006, the script should retrieve 21/08/2006 as start date. Is there any script/code to... (2 Replies)
Discussion started by: ritzwan0
2 Replies
Login or Register to Ask a Question