in reply to Adding Days To YYYYMMDD Date Format

Here's another option:

use Modern::Perl; use Date::Calc qw(Add_Delta_Days); say addDaysToDate( 20120516, 24 ); sub addDaysToDate { sprintf '%d%02d%02d', Add_Delta_Days( $_[0] =~ /(\d{4})(\d{2})(\d{2})/, $_[1] ); }

Output:

20120609

Hope this helps!

Replies are listed 'Best First'.
Re^2: Adding Days To YYYYMMDD Date Format
by Zoomie (Novice) on May 17, 2012 at 21:09 UTC

    I got error with the Modern::Perl.

    Thanks...

Re^2: Adding Days To YYYYMMDD Date Format
by Zoomie (Novice) on May 25, 2012 at 15:33 UTC

    Hi Kenosis

    I added the module Modern::Perl, ran your script, but the result is not correct.

    I changed your sprintf '%d%02d%02d' to sprintf '%04d%02d%02d'.

    Using the same sample, it prints out 00001200.

    <Thanks...

Re^2: Adding Days To YYYYMMDD Date Format
by Zoomie (Novice) on May 30, 2012 at 20:53 UTC

    Kenosis.

    It works now!

    Thanks very much!