Hello,

For a program that I'm writing atm I have to calculate the number of months between two dates. The months format is 2005-11-17 and I've been able to get a nice delta with the time in between de two dates.

I've done it like this:
$implantdate="2000-11-07"
$fudate="2005-11-15"

I've done a check that $fudate is an higher date then the implantdate. So that I get an positive numer.

my $date1 = ParseDate($implantdate);
my $date2 = ParseDate($fudate);
my $delta = DateCalc($date1,$date2,\$err,1);

the 1 standing for approximate mode, then he uses yMwdhms
The delta between the two dates is +5:0:1:1:0:0:0
So thats 5 years 0 months 1 week and 1 day

To get the date I tried:
my @format;
$format[0] = "%Mt";
my $str = Delta_Format($delta,2,@format);
Like this the output of string is: str=60.00

But with this it didnt take a look at the weeks, days etc
I've found out that it was because of
<quote cpan>
Delta_Format can operate in two modes: exact and approximate. The exact mode is done by default. Approximate mode can be done by passing in the string "approx" as the 2nd argument. In exact mode, Delta_Format only understands "exact" relationships. This means that there can be no mixing of the Y/M and W/D/H/MN/S segments because the relationship because, depending on when the delta occurs, there is no exact relation between the number of years or months and the number of days. </quote cpan>

but when I take a look at the Cpan for the complete function:
$str = Delta_Format($delta [,$mode], $dec,@format);

I'm stuck
I've tried a number of things
$str = Delta_Format($delta,"approx",2,@format);
The output of str is then str=2 60.000000
So for one reason or another it makes 2 also a string. And it doesnt use it anymore. I also tried to put the approx in the $delta .. well ofcourse that didnt work either.

And I did set the correct timezone for Date::Manip

I cant seem to find anything other in the manpages about this. And on the web I cant seem to find anyone that uses the approx.

I really hope that you guys can help me on this matter

Thanks in advance
Rianne Ubbink

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to