I need to get the difference of two days from perl. ( I need only to get the difference in no of days) eg 12/2/2007 - 15/2/2007 diff is 3my date format is 15/2/2007.
if two dates in two months then subtracting method will not work right.Ill try to do ti Manip. in there am I have to format the date before passing toDateCalc
Additional date formats are available which may or may not be com- mon including: MM/DD ** MM/DD/YY ** MM/DD/YYYY ** mmmDD DDmmm mmmYYYY/DD mmmYYYY mmmDD/YY DDmmmYY DD/YYmmm YYYYmmmDD YYYYmmm mmmDDYYYY DDmmmYYYY DDYYYYmmm YYYY/DDmmm Where mmm refers to the name of a month. All parts of the date can be separated by valid separators (space, "/", or "."). The separa- tor "-" may be used as long as it doesn't conflict with an ISO 8601 format, but this is discouraged since it is easy to overlook con- flicts. For example, the format MM/DD/YY is just fine, but MM-DD- YY does not work since it conflicts with YY-MM-DD. To be safe, if "-" is used as a separator in a non-ISO format, they should be turned into "/" before calling the Date::Manip routines. As with ISO 8601 formats, all separators are optional except for those given as a "/" in the list above. ** Note that with these formats, Americans tend to write month first, but many other countries tend to write day first. The lat- ter behavior can be obtained by setting the config variable Date- Format to something other than "US" (see CUSTOMIZING DATE::MANIP below).... DateFormat Different countries look at the date 12/10 as Dec 10 or Oct 12. In the United States, the first is most common, but this certainly doesn't hold true for other countries. Setting DateFormat to "US" forces the first behavior (Dec 10). Setting DateFormat to anything else forces the second behavior (Oct 12).
use Date::Manip;my $date1 = ParseDate("10/01/2006");my $date2 = ParseDate("today");my $err = undef;print "Date1 =" + $date1 + "\n";#print "\n";print "Date2 =" + $date2 + "\n";#print "\n";my $DeltaDate = DateCalc($date1,$date2,\$err);print "Date Diff =" + $DeltaDate + "\n";in here DeltaDate is getting 0 can you correct this code?
use strict;use warnings;use Date::Manip;my $date1 = ParseDate("10/01/2006");my $date2 = ParseDate("today");my $delta = Delta_Format(DateCalc($date1, $date2), undef, undef, "%dh");print "Delta: $delta days\n";