Computing.Net > Forums > Unix > A week back date

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

A week back date

Reply to Message Icon

Name: Chinmaya
Date: April 4, 2006 at 08:35:55 Pacific
OS: Unix
CPU/Ram: 128
Product: 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



Sponsored Link
Ads by Google

Response Number 1
Name: lchi2000g
Date: April 4, 2006 at 12:54:44 Pacific
Reply:

see - http://www.computing.net/unix/wwwboard/forum/6212.html

Luke Chi


0

Response Number 2
Name: Chinmaya
Date: April 4, 2006 at 20:30:34 Pacific
Reply:


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


0

Response Number 3
Name: nails
Date: April 5, 2006 at 07:51:41 Pacific
Reply:

Take a look at this link:

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


0

Response Number 4
Name: FishMonger
Date: April 5, 2006 at 08:37:03 Pacific
Reply:

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));



0

Response Number 5
Name: FishMonger
Date: April 5, 2006 at 08:43:22 Pacific
Reply:

From the command line:

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


0

Related Posts

See More



Response Number 6
Name: Chinmaya
Date: April 5, 2006 at 20:42:51 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: A week back date

Get a week number from a date. www.computing.net/answers/unix/get-a-week-number-from-a-date/8510.html

Getting a file julian date www.computing.net/answers/unix/getting-a-file-julian-date/7548.html

Displaying date-7 in AIX www.computing.net/answers/unix/displaying-date7-in-aix/7691.html