Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

A week back date

Original Message
Name: Chinmaya
Date: April 4, 2006 at 08:35:55 Pacific
Subject: A week back date
OS: Unix
CPU/Ram: 128
Model/Manufacturer: HP-UX
Comment:
Hi

I would like to get a week back date.
Suppose today is 04-04-2006 , then a week back date is 28-03-2006. Could you please tell me how I can achieve this in unix command.
Can I get this result using 'date' command.

Thanks and Regards
Chinmaya


Report Offensive Message For Removal


Response Number 1
Name: lchi2000g
Date: April 4, 2006 at 12:54:44 Pacific
Subject: A week back date
Reply: (edit)
see - http://www.computing.net/unix/wwwboard/forum/6212.html

Luke Chi


Report Offensive Follow Up For Removal

Response Number 2
Name: Chinmaya
Date: April 4, 2006 at 20:30:34 Pacific
Subject: A week back date
Reply: (edit)

Hi Luke

Many thanks for your reply.

I found from the link specified by you , we can get yesterday's date by assignment
TZ=aaa24 date +%Y%m%d.

But I am not able to get logic , how we can find a week back date.

Could you please help me on this


Thanks and Regards
Chinmaya


Report Offensive Follow Up For Removal

Response Number 3
Name: nails
Date: April 5, 2006 at 07:51:41 Pacific
Subject: A week back date
Reply: (edit)
Take a look at this link:

http://www.computing.net/unix/wwwboard/forum/5223.html


Report Offensive Follow Up For Removal

Response Number 4
Name: FishMonger
Date: April 5, 2006 at 08:37:03 Pacific
Subject: A week back date
Reply: (edit)
I would agree with the suggestion nails made in that second link, "...Perl is probably your best choice...".

This is the Perl command for retrieving the date/timestamp of exactly 1 week prior to the current date/time.

$lastweek = localtime(time - 86400*7);

Here's how you'd format it like your example dd-mm-yyyy.

use POSIX;
$lastweek=strftime("%d-%m-%Y",localtime(time-86400*7));



Report Offensive Follow Up For Removal

Response Number 5
Name: FishMonger
Date: April 5, 2006 at 08:43:22 Pacific
Subject: A week back date
Reply: (edit)
From the command line:

perl -MPOSIX -e 'print strftime("%d-%m-%Y",localtime(time-86400*7))'


Report Offensive Follow Up For Removal


Response Number 6
Name: Chinmaya
Date: April 5, 2006 at 20:42:51 Pacific
Subject: A week back date
Reply: (edit)
Hi Luke, Nails, Monger

Many thanks for your reply.

As per user suggesstion, I could get the a week back date.

Thanks and Regards
Chinmaya


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: A week back date

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




acer 312T BIOS problem

K7 Turbo possible max fsb?

Pc anywher problem

WinFLP & OE/Outlook2003

Computer resets after a few minutes


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC