Last weeks date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Last weeks date
# 1  
Old 08-01-2012
Error Last weeks date

I am unable to get the last week date i tried to use the following commands but i failed
Please help, and am using HP unix
Code:
date -d "+1 week"
date --date=yesterday +%y%m%d

# 2  
Old 08-01-2012
# 3  
Old 08-01-2012
I did not got the solution from the above link, please help i need the last week's date and yesterdays date.....
# 4  
Old 08-01-2012
Code:
$ perl -e 'print localtime(time() - 86400) . "\n" '
Tue Jul 31 08:32:31 2012
$ perl -e 'print localtime(time() - 7*86400) . "\n" '
Wed Jul 25 08:32:39 2012

https://www.unix.com/answers-frequent...rithmetic.html
# 5  
Old 08-01-2012
How to get the date in dd/mm/yyyy format using the above command
# 6  
Old 08-01-2012
Try:
Code:
$ perl -e 'use POSIX strftime; print POSIX::strftime("%d/%m/%Y\n", localtime(time()-7*86400))'
26/07/2012

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move log files with date and delete older than 3 weeks

I have written a script which generate one logfile on every sunday and thursday I want to move the older log files into /tmp directory befor generating new one so i used mv command like mv usr/sbin/appl/logfile.txt usr/sbin/appl/tmp 2) But when i move this file to /tmp it will... (1 Reply)
Discussion started by: Nakul_sh
1 Replies

2. Solaris

date -d "-2 weeks" on Solaris

Hi, I am trying to find solution how to get this on Solaris machine: $ MY_DATE=`date +%m/%d/%Y -d "-2 weeks"` $ echo $MY_DATE 07/01/2009 On Linux machine I can use flags like "+2 weeks", "+1 month", etc. but this doesn't work on Solaris. What is the most simplest way to write `date... (1 Reply)
Discussion started by: shtuks
1 Replies

3. Shell Programming and Scripting

how to check whether the given file is 5 weeks older than current date

HI, I need to check whether the given file is 5 weeks older than current date ?? Can anyone give me the script for this ?? (1 Reply)
Discussion started by: risshanth
1 Replies

4. Shell Programming and Scripting

find a date two weeks ago?

Anyone got a script or suggestion for this? I want to find the date when a parameter in days is supplied.. ie.. parameter can be any number for example 15... and the date returned should then be 15 days ago... or 31 and the date returned should be 31 days ago... Any ideas on best way to... (2 Replies)
Discussion started by: frustrated1
2 Replies

5. Shell Programming and Scripting

How many weeks in a year

Hi, I search how i could do to find if a year (for example 2004, 1989, 2058) has 52 or 53 weeks... Have you a idea for me please??? (1 Reply)
Discussion started by: Castelior
1 Replies
Login or Register to Ask a Question