in reply to Re: Re: Calculating date from a fixed point
in thread Calculating date from a fixed point

Enlil,

One More Question if you would allow me.

How to push the result to a variable? I tried the following and it worked but the formatting was of course lost doing it this way.

what I did

use Date::Calc qw/Add_Delta_Days/; my $delta = 72583; my ($year,$month,$day) = Add_Delta_Days(1800,12,28,$delta); $newdate = $year$month$day; printf "$newdate \n";
which gave me 1999919
I need it to be YYYMMDD.

How do I put this to a variable with the formatting you used?

thanks for your great help =)

aschroh

Replies are listed 'Best First'.
Re: RE: Calculating date from a fixed point
by Enlil (Parson) on Apr 17, 2003 at 21:28 UTC
    I am glad this helped.

    To keep the formatting you can use sprintf. (printf, "is equivalent to print FILEHANDLE sprintf(FORMAT, LIST), except that $\ ... is not appended").

    So your code would now look like this. :

    use Date::Calc qw/Add_Delta_Days/; my $delta = 72583; my ($year,$month,$day) = Add_Delta_Days(1800,12,28,$delta); $newdate = sprintf("%4d%02d%02d", $year, $month, $day); print "$newdate\n";

    -enlil

      Thank You Once again!!! =) aschroh