Extract Monday from given date


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Extract Monday from given date
# 1  
Old 05-28-2008
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  
Old 05-28-2008
try searching here
# 3  
Old 05-29-2008
It may not be obvious how to use datecalc to find Monday.
Code:
$ echo $(datecalc -d 2008 05 28)
3
$ #  That 3 means it is Wed
$ echo $((1 - $(datecalc -d 2008 05 28) ))
-2
$ # How much we are off from Mon
$ echo $(datecalc -j 2008 05 28)
54614
$ # mjd of input date
$ echo $(( $(datecalc -j 2008 05 28) + 1 - $(datecalc -d 2008 05 28) ))
54612
$ #mjd of Monday
$ datecalc -j $(( $(datecalc -j 2008 05 28) + 1 - $(datecalc -d 2008 05 28) ))
2008 5 26
$ #desired output
$

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract date / time

How do i display in the below format without the brackets using shell script. Tue Oct 1 13:32:40 2013 Please use CODE tags not only for all code segments, input samples, and output samples. (7 Replies)
Discussion started by: ghosh_tanmoy
7 Replies

2. Shell Programming and Scripting

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 (5 Replies)
Discussion started by: balasubramani04
5 Replies

3. Shell Programming and Scripting

Extract week start,end date from given date in PERL

Hi All, what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case week start date will be-:12/19/2011... (2 Replies)
Discussion started by: parthmittal2007
2 Replies

4. 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

5. 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

6. 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

7. Shell Programming and Scripting

extract date

I run few command from c shell script and after this i want to check the status. I write the following code and it give the error message like "Variable Syntax". Here is my code: #/ !/bin/csh -f rm -f <filename> if ($? != 0) then echo " command does not executed successfully!" end... (3 Replies)
Discussion started by: skumar11
3 Replies
Login or Register to Ask a Question