Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date - 30 1

Status
Not open for further replies.

chapm4

IS-IT--Management
Nov 12, 2001
38
US
Hi,
I need to run a script that uses a variable that is 30 days ago from the date the script is run. In looking over the previous questions I am currently getting the date by using:

date '+%Y/%m/%d'

I have tried several variations to subtract 30, but am having no luck.
 
Try this -

$ date
Wed Jan 26 16:05:44 GMT 2000
$
$ TZ=GMT+168 date
Wed Jan 19 16:04:40 GMT 2000
$
$ date
Wed Jan 26 16:05:44 GMT 2000

I'll leave you to work out how many hours 30 is!

Steve
 
See faq80-953 . It shows how to get yesterday's date. Set TZ to 24*30 to get the date 30 days ago
Hope this helps. CaKiwi
 
For those into perl, there is a datecalc
function that handles date & time math better
than any other fuction I have seen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top