Changing date regularly..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Changing date regularly..
# 1  
Old 10-08-2008
Changing date regularly..

Hi Guys,
Plzz help me out in this!!!!!!!!!!!!!!!!

I have a file which runs in the back ground using crontab for every monday at5 P.M. The problem is inside the file ...

This is a sample content of a file

Update the current and previous week: (Sunday to Sunday)
%let wk_curr=20070930;
%let wk_prev=20070923


Here i need to change the dates regularly i.e. every week. before the job starts running on monday..

(20070923 is a sunday and also 20070930 is a sunday)

so wen the job runs for th next time, i need the dates to be like

%let wk_curr=20071007;
%let wk_prev=20070930;


there is no problem if the dates are changing within a month but in the case of last date of the month ,its not getting updated properly..


plzzz guide me in this as it s very urgent


Regards,
Anand
# 2  
Old 10-08-2008
man date and/or https://www.unix.com/answers-frequent...rithmetic.html from this site's FAQ section.
# 3  
Old 10-08-2008
HI,
I checked out but am not able to find the answer..Please guide me in this
# 4  
Old 10-08-2008
today=`date +"%Y%m%d"`
echo "$today" > /var/tmp/NEWDATEFILE
echo "current date= $today"
olddate=`cat /var/tmp/NEWDATEFILE`
echo "privious date= $olddate"
####################
#your main logic
####################
# 5  
Old 10-08-2008
Hi Rahul,
Thanks for the reply..Have done this part but i need to the generate dates periodically.plzz help me out in this
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

Changing date format

how do i change the following to show me what the date was 7 days ago? date +%Y-%m-%d (1 Reply)
Discussion started by: SkySmart
1 Replies

3. Shell Programming and Scripting

Changing Date Format

How can i make the date command output yesterday's date, current date and the date 4 days ago, in the following format: 2012-10-03 code: date +% ???? (3 Replies)
Discussion started by: SkySmart
3 Replies

4. Shell Programming and Scripting

changing date to resemble "messages file" date

the following was taken from a perl script: my $date = strftime "%B %d %H:%M:%S", localtime; how can i modify it so this date outputs the date in the form of the date of the messages file. for example: Sep 20 11:48:44 As it is right now, the perl script outputs the date like this: ... (1 Reply)
Discussion started by: SkySmart
1 Replies

5. Shell Programming and Scripting

Changing Date format

How to change a date stored in a variable to YYYYMMDD. Variable output is in DD-MON-YY,required format is 'YYYYMMDD' Thanks, Sud (1 Reply)
Discussion started by: sud
1 Replies

6. Linux

changing date

Hi, I want to create one user who has right to change the date in linux, (1 Reply)
Discussion started by: manoj.solaris
1 Replies

7. UNIX for Dummies Questions & Answers

Changing Creation Date to a Prespecified Date of a File In Unix

Dear Expert, Is there a command to do that in Unix? In such a way that we don't need to actually "write" or modified the content. -- monkfan (4 Replies)
Discussion started by: monkfan
4 Replies

8. Shell Programming and Scripting

Changing date format

Hi, Is there any way to change one date format to another ?? I mean I have a file having dates in the format (Thu Sep 29 2005) ... and i wud like to change these to YYYYMMDD format .. is there any command which does so ?? Or anything like enum which we have in C ?? Thanks in advance, ... (5 Replies)
Discussion started by: Sabari Nath S
5 Replies

9. Shell Programming and Scripting

Changing the date format

Hi, I know there is a Q/A section and lots of posts regarding date command here. I am sorry to start a new thread. I am very new to shell scripting (actually i am working on my first program), so please forgive my ignorance. I could not find an answer to my problem else where so i posted it... (10 Replies)
Discussion started by: Dream86
10 Replies

10. UNIX for Dummies Questions & Answers

changing the date

I need to change the date of the UNIX server at work to 20 aug 2001. How do I do this? And will this affect any databases running, or do I need to bring all databases down? (2 Replies)
Discussion started by: JBX
2 Replies
Login or Register to Ask a Question