Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Additional line in date-global

Quote Reply
Additional line in date-global
Hi to all,

i am using this global to view a SUM of data-records with a special value in colun "Ausgabe":
sub {
my $cond = new GT::SQL::Condition;
my ($total) = $DB->table('Links')->select(['SUM(Wert)'],$cond)->fetchrow_array;
local $_ = int $total;
1 while
return "$_";

The using is:
1. I define the "Ausgabe" from the actual date and
2. put this Ausgabe (format: mm-yyyy) into global like this:

<%set Ausgabe = GT::Date::date_transform($date, '%dd%.%mm%.%yyyy%', '%mm%-%yyyy%')%>

Now what i need is this:
When the actual "Ausgabe" is not in db (e.g. 02-2005), then the global search for the last available date, in this case: 01-2005.
Perhaps: IF $total = 0 ...... etc ....... ???

How can i do that?

Thanks in advance!

Quote Reply
Re: [Coyu] Additional line in date-global In reply to
Something like this before the original select should get the closest value:my $db1=$DB->table('Links');
$db1->select_options (ORDER BY Ausgabe DESC LIMIT 1);
my $cond1= GT::SQL::Condition->new('Ausgabe','<=',$ausgabe);