Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date problem

Status
Not open for further replies.

PerlElvir

Technical User
Aug 23, 2005
68

Im begginer so if can help me... :0)

So I have two dates and I want to multiply by n number.

Example:

first_date = 21.10.2005
seconde_date = 20.11.2005

Now I want first date to multiplay for 5(or any number what I want) and I have to get:

26.10.2005
31.10.2005
05.11.2005
.
.
.
20.11.2005

So if someone can help I'll be greateful
 
Because we are not allowed to help with schoolwork.
Anyway, here goes then:

Code:
#!/usr/bin/perl -w
use strict;
use Date::Calc qw(Add_Delta_Days);
my $date1 = "21.10.2005";
my $date2 = "20.11.2005";
my $delta = 5;
my ($day1, $month1, $year1) = split(/\./,$date1,3);
my ($day2, $month2, $year2) = split(/\./,$date2,3);
print "$day1.$month1.$year1\n";
while($year1 < $year2 or $month1 < $month2 or $day1 < $day2) {
  ($year1, $month1, $day1) = Add_Delta_Days($year1,$month1,$day1,$delta);
  print "$day1.$month1.$year1\n";
}


Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top