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

Displaying date-7 in AIX

Original Message
Name: sureshht
Date: February 6, 2007 at 12:04:03 Pacific
Subject: Displaying date-7 in AIX
OS: AIX 5L
CPU/Ram: 4 CPU/8GB RAM
Model/Manufacturer: IBM AIX RS6000
Comment:
Hi,

How can I display date-7 in AIX?
I want to print a date of one week back.
Can I do it in AIX?

Thanks
Suresh

sureshht


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: February 6, 2007 at 13:49:32 Pacific
Subject: Displaying date-7 in AIX
Reply: (edit)
Are you looking at doing this in a Unix shell script?

Report Offensive Follow Up For Removal

Response Number 2
Name: nails
Date: February 6, 2007 at 13:50:55 Pacific
Subject: Displaying date-7 in AIX
Reply: (edit)
Because if you are, it's time for William to do his thing:

http://www.computing.net/unix/wwwbo...


Report Offensive Follow Up For Removal

Response Number 3
Name: sureshht
Date: February 12, 2007 at 12:53:03 Pacific
Subject: Displaying date-7 in AIX
Reply: (edit)
Hi,
I am doing some work with logs on a weekly basis. I will check some files and finally print the error.If I dont find any error in a weeks time, I just want to print "no errors forund since "7 days back date".

Thanks
Suresh

sureshht


Report Offensive Follow Up For Removal

Response Number 4
Name: nails
Date: February 13, 2007 at 11:04:54 Pacific
Subject: Displaying date-7 in AIX
Reply: (edit)
Did you even try shift_dates? Copy shift_dates into a directory. It's available from at least two sites mentioned in the other thread. Create another script that calls shift_dates:

#!/bin/ksh

# today's date
todays_date=$(date '+%Y%m%d')

# shift_dates is in the current directory. William's shift_date expects
# date in YYYYMMDD format
# seven days back
date7back=$(./shift_dates $todays_date -7)

echo $date7back


Report Offensive Follow Up For Removal

Response Number 5
Name: sureshht
Date: February 16, 2007 at 09:58:31 Pacific
Subject: Displaying date-7 in AIX
Reply: (edit)
I tried this and it works fine.
But,I want date-7 in mm/dd/yyyy format.
Any idea?

Thanks
Suresh

sureshht


Report Offensive Follow Up For Removal


Response Number 6
Name: nails
Date: February 17, 2007 at 07:50:08 Pacific
Subject: Displaying date-7 in AIX
Reply: (edit)
I see two choices: Either change the shift_date function's date argument or create a driver function that changes your format to the shift_date format, calls shift_date, and then changes the format back you your format. This program does that:

#!/bin/ksh

# this function requires
# $1 is date in mm/dd/yyyy format
# $2 is the number of days to shift
# return the date in mm/dd/yyyy format
function sd_driver {
typeset -i nodays

nodays=$2

# parse mm/dd/yyyy
set -- $(IFS="/"; echo $1)

newdate=$(./shift_date.ss $3$1$2 $nodays)
yy=$(echo $newdate|cut -b 1-4)
mm=$(echo $newdate|cut -b 5-6)
dd=$(echo $newdate|cut -b 7-8)
echo $mm/$dd/$yy
}

nd=$(sd_driver "02/28/2007" 1)
echo $nd


Report Offensive Follow Up For Removal

Response Number 7
Name: thepubba1
Date: February 19, 2007 at 16:52:36 Pacific
Subject: Displaying date-7 in AIX
Reply: (edit)
I was a little bored today, so I wrote this script to do julian - 365. I did no checking so if you put in a number that puts you back 2 years, you can modify it to work properly.

integer today=$(date +%j)
print "Enter the number of days to subtract: \c"
read daysToDelete

currentYear=$(date +%Y)
newJulian=$(print "$today - $daysToDelete" | bc )
echo $newJulian

for days in $(cal 2 $lastYear)
do
:
done

if [[ $newJulian -le 0 ]]
then
print "We're working with a date from last year"
(( lastYear = currentYear - 1 ))
if [[ $days -eq 29 ]]
then
print "Last year was a leap year"
julianDate=$(echo "366 $newJulian" | bc )
leapYear=1
year=$lastYear
else
print "Last year was a not a leap year"
julianDate=$(echo "365 + $newJulian" | bc )
year=$lastYear
fi
else
julianDate=$newJulian
year=$currentYear
fi

typeset -R2 year

if [[ $julianDate -eq 0 ]]
then
print "Date is $year/12/31"
exit 0
fi

if [[ $julianDate -le 31 ]]
then
print "Date is $year/01/$julianDate"
exit 0
fi

(( julianDate -= 31 ))

if [[ $leapYear -eq 1 && $julianDate -le 29 ]]
then
print "Date is $year/02/$julianDate"
exit 0
elif [[ $julianDate -le 28 ]]
then
print "Date is $year/02/$julianDate"
exit 0
fi

if [[ $leapYear -eq 1 ]]
then
(( julianDate -= 29 ))
else
(( julianDate -= 28 ))
fi

if [[ $julianDate -le 31 ]]
then
print "Date is $year/03/$julianDate"
exit 0
fi
(( julianDate -= 31 ))

if [[ $julianDate -le 30 ]]
then
print "Date is $year/04/$julianDate"
exit 0
fi
(( julianDate -= 30 ))

if [[ $julianDate -le 31 ]]
then
print "Date is $year/05/$julianDate"
exit 0
fi
(( julianDate -= 31 ))

if [[ $julianDate -le 30 ]]
then
print "Date is $year/06/$julianDate"
exit 0
fi
(( julianDate -= 30 ))

if [[ $julianDate -le 31 ]]
then
print "Date is $year/07/$julianDate"
exit 0
fi
(( julianDate -= 31 ))

if [[ $julianDate -le 31 ]]
then
print "Date is $year/08/$julianDate"
exit 0
fi
(( julianDate -= 31 ))

if [[ $julianDate -le 30 ]]
then
print "Date is $year/09/$julianDate"
exit 0
fi
(( julianDate -= 30 ))

if [[ $julianDate -le 31 ]]
then
print "Date is $year/10/$julianDate"
exit 0
fi
(( julianDate -= 31 ))

if [[ $julianDate -le 30 ]]
then
print "Date is $year/11/$julianDate"
exit 0
fi
(( julianDate -= 30 ))

print "Date is $year/12/$julianDate"
$


Report Offensive Follow Up For Removal

Response Number 8
Name: sureshht
Date: February 20, 2007 at 10:34:22 Pacific
Subject: Displaying date-7 in AIX
Reply: (edit)
Thanks a lot guys

Suresh

sureshht


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: Displaying date-7 in AIX

Comments:

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


Data Recovery Software




My PC has been hijacked!

Lexmark 2600 Printer Issues

btk1w1 infected start here post

Unwanted message remians on screen

Slow boot time


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