The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can i calculate a Quarter of a Month pidu_rak UNIX for Advanced & Expert Users 2 12-26-2007 12:47 PM
calculate 13 months ago andrea_mussap Shell Programming and Scripting 4 11-21-2007 08:14 PM
calculate 13 months ago andrea_mussap Shell Programming and Scripting 3 11-16-2007 03:18 PM
Subtract 2 months from the date mahekr2000 UNIX for Advanced & Expert Users 5 07-23-2006 12:01 PM
Subtracting Two months from date jwatson12 UNIX for Dummies Questions & Answers 3 09-13-2002 01:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-17-2007
new2ss new2ss is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 133
Cron to run first day of month to calculate date 3 months ago

Hi,

I would like to find out how can i calculate a date which is 3 months ago. I intend to run a cron job on the 1st of every month, and calculate the month 4 months earlier from the date. For example, if today's date is 1st May 2007, i would like to return 012007( January 2007).
i can get today's date by
Code:
'date +%Y%m%d`
is there a similar one liner or a few lines to achieve my result? would appreciate if anyone can shed some light. Thank you.
  #2 (permalink)  
Old 05-17-2007
new2ss new2ss is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 133
sorry, found many similar threads in the forum.

because i am using GNU date, i can get it by
Code:
date -d " x months ago"
depending how many months i need, just replace x with the require number.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0