Date calculations are always a pain!
I'm writing some availability reports.
this_month.ksh is easy - period start is 01/$(date +%m/%y) and period end is $(date +%d/%m/%y)
However, I'm now writing last_month.ksh. Period start is relatively easy - something along the lines of
Ok, I know I need to allow for January but that's not the problem.
Has anyone any ideas of how to generate period end? The two options I'm looking at are some sort of lookup table (a kop out!) or to use PHV's date calculatore (see FAQ822-4802) and loop backwards one day at a time untill I hit last month i.e. in pseudo code
but that's a bit clumsy and slow.
Has anyone any ideas?
Ceci n'est pas une signature
Columb Healy
I'm writing some availability reports.
this_month.ksh is easy - period start is 01/$(date +%m/%y) and period end is $(date +%d/%m/%y)
However, I'm now writing last_month.ksh. Period start is relatively easy - something along the lines of
Code:
typeset -Z 2 LAST_MONTH=$(date +%m)
((LAST_MONTH -= 1))
PERIOD_START=01/$LAST_MONTH/$(date +%y)
Has anyone any ideas of how to generate period end? The two options I'm looking at are some sort of lookup table (a kop out!) or to use PHV's date calculatore (see FAQ822-4802) and loop backwards one day at a time untill I hit last month i.e. in pseudo code
Code:
OFFSET=24
while TRUE
do
calc date from offset
if month = current month - 1 end
OFFSET += 24
done
Has anyone any ideas?
Ceci n'est pas une signature
Columb Healy