Hello,
I’m having an interesting time trying to get the following code to work using your coreutils date program. I’m trying to get the date for Wednesday of the current week. This is running in a Korn shell on an AIX 5.3 (AIX 64) platform.
MDOW1=$(${SBIN}/date +%w)
let MDOW=$MDOW1-1
let WDOW=$MDOW-2
MONYYYYMMDD=$(${SBIN}/date -d"${manYY}-${manMM}-${manDD} -$MDOW day" +%Y-%m-%d)
MONMMDDYYYY=$(${SBIN}/date -d"${manYY}-${manMM}-${manDD} -$MDOW day" +%m%d%Y)
MONDAYDDMMMYYYY=$(${SBIN}/date -d"${manYY}-${manMM}-${manDD} -$MDOW day" +%d%b%Y)
WEDYYYYMMDD=$(${SBIN}/date -d"${manYY}-${manMM}-${manDD} -($WDOW) day" +%Y%m%d)
WEDMMDDYYYY=$(${SBIN}/date -d"${manYY}-${manMM}-${manDD} -($WDOW) day" +%m%d%Y)
WEDDAYDDMMMYYYY=$(${SBIN}/date -d"${manYY}-${manMM}-${manDD} -($WDOW) day" +%d%b%Y)
The 3 MONxxx and 3 WEDxxx variables are all exported. I’m having trouble with the WED dates. On Monday and Tuesday, the WEDxxx variables correctly displayed Mar 21, 2012, in their various formats. But today on Wed, the 21st, they are displaying the Mar 22nd.
WAP:/opt/freeware/bin> echo $MDOW1 $MDOW $WDOW
3 2 0
WAP:/opt/freeware/bin> echo $MONYYYYMMDD $MONMMDDYYYY $MONDAYDDMMMYYYY
2012-03-19 03192012 19Mar2012
WAP:/opt/freeware/bin> echo $WEDYYYYMMDD $WEDMMDDYYYY $WEDDAYDDMMMYYYY
20120322 03222012 22Mar2012
WAP:/opt/freeware/bin>
Any assistance you can provide would be greatly appreciated. The target date is day 3 of the current week, with Monday being the 1. Just to clarify, on Sunday, I am looking for the previous Wednesday date.
Thank you!
Richard (Rick) Morin
Bank of America
VP, Market Information Mgr I
GCSBB Marketing - Global Strategy & Marketing
DIRECT RESPONSE / ANALYTICAL MARKETING
904.783.1727
FL8-054-01-01
Instant recognition is a very powerful motivator.
Please recognize our associates by following the link below.