Hi All,
I want to find the previous day's date and store that in a variable, which will be usuful for further processing.
Any help please.
Regards,
raju
Hi All,
I want to find the previous day's date and store that in a variable, which will be usuful for further processing.
Any help please.
Regards,
raju
This is exactly what you want:
a=$(perl -w -e '@mytime=localtime (time - $ARGV[0]); printf "%d%.2d%.2d", $mytime[5]+1900,$mytime[4]+1,$mytime[3];' 86400)
echo $a
You could have also gotten help from the perl man pages. Check perlfunc in particular.
Thanks Blowtorch.
As a unix command its working fine, I tried to put in my perl program and made the changes to assign the previous date(format mm/dd/yyyy) to a variable but its not working fine.
Could you please look at once.
thanks,
raju
The command I gave will give the output in the yyyy/mm/dd format. You will have to switch the mytime[x] around to get the output in the format that you want.
And another thing, are you using that snippet in a perl program? Then you can use this:
@mytime=localtime (time - 86400);
#from this point on, you can use $mytime[3] for day, $mytime[4] for month (zero based) and $mytime[5] for the year (add 1900)
Thanks blowtorch