adding or subtracting days in the o/p of date


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers adding or subtracting days in the o/p of date
# 1  
Old 05-19-2008
adding or subtracting days in the o/p of date

how can we add or subtract days from the output of date command in unix...

like if i want to subtract a day from the result of date command like this..
v_date=`date +%Y%m%d`
this wud give me 20080519
now i want to subtract one day from this.. so tht it wud give me 20080518..

how do i do this??

also if i want to put a cond if its a thursday then sub 3 days from the date.. so tht it gives me monday's date..

how to do this???
# 2  
Old 05-19-2008
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Changing CSV files with date . Subtracting date by values

Hi All, I have a CSV file which is as below. Basically I need to take the year column in it and find if the year is >= 20152 . If that is then I should subtract all values by 6. In the below example in description I am having number mentioned as YYWW so I need to subtract those by -5. Whereever... (8 Replies)
Discussion started by: arunkumar_mca
8 Replies

2. Shell Programming and Scripting

awk - Adding and Subtracting Numbers from 2 Columns

Hi Folks, I have a file with 2 columns TAB delimited and I want to add '1' to the first column and subtract '-1' from the second column. What I have tried so far is; awk -F"\t" '{ $1-=1;$2+=1}1' OFS='\t' file File 0623 0623 0624 0624 0643 0643 1059 1037 1037 1037 1038 1038... (2 Replies)
Discussion started by: pshields1984
2 Replies

3. Shell Programming and Scripting

Adding days to date

Hi, please can somebody let me know the easiest way to add days to a date. I can do this in perl but would like to able to do it in a shell script. Desired output would be: date +'%Y-%m-%d' + 10 = 2016-05-02 Thank you (8 Replies)
Discussion started by: andy391791
8 Replies

4. UNIX for Dummies Questions & Answers

Subtracting number of days from current date

Hi All, I am using KSH shell and need to subtract n number of days from the current date .. kindly suggest ! Thanks in advance!:) (20 Replies)
Discussion started by: dev.devil.1983
20 Replies

5. Shell Programming and Scripting

Adding/ Subtracting from Date

Hi , How can I add/substruct x number of days with date? For example My_Date=`date` Now I need Hope it's clear. (2 Replies)
Discussion started by: Anupam_Halder
2 Replies

6. UNIX for Dummies Questions & Answers

Static date adding and subtracting years

Hi Gurus! I have a static date in a YYYYMMDD format; and I want get the date 2 years in the past and 2 years in the future. static_date=20010203 old_date=$static_date - 3 years future_date=$static_date + 2 years I was only able to research on dates that are current and not on static... (3 Replies)
Discussion started by: kokoro
3 Replies

7. Shell Programming and Scripting

Adding days to system date then compare to a date

Hi! I am trying to read a file and every line has a specific date as one of its fields. I want to take that date and compare it to the date today plus 6 days. while read line do date=substr($line, $datepos, 8) #date is expected to be YYYYMMDD if ; then ...proceed commands ... (1 Reply)
Discussion started by: kokoro
1 Replies

8. Windows & DOS: Issues & Discussions

Adding or subtracting days from current date in batch script

Hi, I'm writing an batch file to create report In the batch file iam passing two arguments:startdate and finishdate Ex: startdate=07-sep-2009 finishdate=07-sep-2011 I need to have script that takes command line argument as input and gives me out currentdate last year and current date... (2 Replies)
Discussion started by: anand1773
2 Replies

9. Shell Programming and Scripting

Adding days to an input date.

Hello Unix gurus, I need to add days to the input date and further use it in comparision with the existing date. Im having issues sto add days to date,can you guys help me with script or function with which I can add days to the date. Thanks, Sud (10 Replies)
Discussion started by: sud
10 Replies

10. Shell Programming and Scripting

subtracting a days from current date

Hi i am trying to subtract days from current date. For example todays date is 10/03/2006. If i subtract 2 days it should give 8/03/2006. I am also trying to find the access date of a file in dd/mm/yyyy format. Can any one please help in how to do this. Ramesh (1 Reply)
Discussion started by: rameshspal
1 Replies
Login or Register to Ask a Question