views:

786

answers:

1

Current code opens up an Outlook Calendar database as follow:

my $outlook = Win32::OLE->GetActiveObject('Outlook.Application') || Win32::OLE->new('Outlook.Application', 'Quit');

my $namespace = $outlook->GetNamespace("MAPI");

## only fetch entries from Jan 1, 2007 onwards
my $restrictDates = "[Start] >= '01/01/2007'";
+1  A: 

Since you don't show the code that gets the date of your object, this question is impossible to answer without some knowledge of the Outlook object you are trying to access.

If you have an array of objects you can sort them by date and filter ones prior to a certain one.

my $sub = sub {
    my $ad = $a->date_string_accessor;
    my $bd = $b->date_string_accessor;
    $ad =~ s:(\d+)/(\d+)/(\d+):$3 . sprintf('%0d', $1) . sprintf('%0d', $2):e;
    $bd =~ s:(\d+)/(\d+)/(\d+):$3 . sprintf('%0d', $1) . sprintf('%0d', $2):e;
    return $ad cmp $bd;
};

my @sorted = sort $sub @unsorted;

print join("\n", @sorted);

But it would seem to me that you should use the application itself to do this -- presumably Outlook has some sort of query/sort functionality.