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

Enlil, This method fit my needs perfectly thanks for your assistance =) aschroh
  • Comment on Re: Re: Calculating date from a fixed point

Replies are listed 'Best First'.
RE: Calculating date from a fixed point
by aschroh (Novice) on Apr 17, 2003 at 20:59 UTC
    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

      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