Tags:
create new tag
, view all tags

Question

Can anyone please tell me what's wrong with this formula?

Fred Blogs 23 Sep 2008
John Doe 24 Oct 2008


%CALC{"$IF( $T(R1:C3) <= $FORMATGMTIME($TIMEADD($TIME(), 2, week), $day $mon $year), $T(R1:C1) $T(R1:C2) , END)"}%

Because I get this result:

ERROR: Illegal octal digit '8', at end of lineIllegal octal digit '8', at end of line

If I replace the FORMATGMTIME section with a date value the IF statement works correctly. Also if I have the FORMATGMTIME section outside of the IF statement it resolves to the expected date.

Environment

TWiki version: TWikiRelease04x00x02
TWiki plugins: DefaultPlugin, EmptyPlugin, SpreadSheetPlugin, TablePlugin, ChartPlugin, CommentPlugin, EditTablePlugin, InterwikiPlugin, PreferencesPlugin, SlideShowPlugin, SmiliesPlugin, TWikiDrawPlugin, WysiwygPlugin
Server OS: Ubuntu Linux 6.06 Kernel
Web server: Apache 2.0.55
Perl version: 5.8.8
Client OS: MS Windows XP SP2
Web Browser: Firefox 2.0.0.16
Categories: Plugins

-- EmmaForrester - 24 Sep 2008

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

You're comparing apples and oranges: a date string with a serialized date.

At the time of this writing, this:

   * 1st term: %CALC{$TIME($T(R1:C3)) -> $T(R1:C3)}%
   * 2nd term: %CALC{$TIMEADD($TIME(), 2, week) -> $FORMATGMTIME($TIMEADD($TIME(), 2, week), $day $mon $year)}%

Returns this:

  • 1st term: 1222153200 -> 23 Sep 2008
  • 2nd term: 1224182478 -> 16 Oct 2008

And comparing like terms:

   1. %CALC{$IF($T(R1:C3) <= $FORMATGMTIME($TIMEADD($TIME(), 2, week), $day $mon $year), $T(R1:C1) $T(R1:C2), END)}%
   2. %CALC{$IF($TIME($T(R1:C3)) <= $TIMEADD($TIME(), 2, week), $T(R1:C1) $T(R1:C2), END)}%

Does this:

  1. END [string comparison, gives wrong result]
  2. Fred Blogs [serial date comparison, gives correct result]

> If I replace the FORMATGMTIME section with a date value the IF statement works correctly

That was probably a fluke. Notice in my example that "23 Sep 2008 <= 16 Oct 2008" is false, since that IF returned "END".

So comparing serial dates, and using FORMATGMTIME outside of the IF statement, is the way to go.

-- SeanCMorgan - 02 Oct 2008

Thank you very much for your help with this mistake of mine.

-- EmmaForrester - 03 Oct 2008

 
Change status to:
Topic revision: r3 - 2008-10-03 - EmmaForrester
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.