SID-01265: Double IF statement in CALC
| Status: |
Answered |
TWiki version: |
5.0.2 |
Perl version: |
Perl 5.8 |
| Category: |
CategoryAPI |
Server OS: |
Ubuntu 8.04 |
Last update: |
13 years ago |
%CALC{$SET(weekold, $TIMEADD($TIME(), -7, day))}%
%CALC{$SET(weekold2, $TIMEADD($TIME(), -14, day))}%
This script finds all topics, that are 2 weeks old(weekold2). How can i change if statement, so i could use between option - topics that are older then 1 week and not more that 2 weeks old?
--
BostjanTovornik - 2011-09-06
Discussion and Answer
Use logical
$AND(). Untested: =$IF($AND($TIME($date) < $GET(weekold2), $TIME($date) > $GET(weekold)) , <nop>, ...
--
PeterThoeny - 2011-09-06
I tried like this:
$percentCALC{$SET(weekold2, $TIMEADD($TIME(), -5 day))}% //to get topics for last 5 days
$percntCALC{$IF($AND(1,$TIME($date) > $GET(weekold2))>0,$date [[$web.$topic][$formfield(Title)]],<nop>)}$percnt
But getting all data anyway,,,
But then i tried like this:
$percntCALC{Date:$TIME($date), Weekold2: $GET(weekold2) $IF($AND(1,$TIME($date) > $GET(weekold2))>0,$date [[$web.$topic][$formfield(Title)]],<nop>)}$percnt
and got:
Date:1315291920, Weekold2: 1315375044 06 Sep 2011 - 08:52 1
Date:1315291740, Weekold2: 1315375044 06 Sep 2011 - 08:49 2
Date:1314620460, Weekold2: 1315375044 29 Aug 2011 - 14:21 3
Date:1314619320, Weekold2: 1315375044 29 Aug 2011 - 14:02 4
Date:1314346860, Weekold2: 1315375044 26 Aug 2011 - 10:21 5
Are those milliseconds? It doesn't look right...
--
BostjanTovornik - 2011-09-07
Those are the seconds since 1st Jan 1970. It comes from the unix world and is a very nice date format, as you can do all the integer comparing - which is not that easy to realize with a customize date format like 09-08-11. So $TIME() gives you the date in seconds to a given date in "normal" format. Have a look at the SpreedSheetPlugin page for more information.
--
CarlaReitzenstein - 2011-09-08
I still have problems with that $AND in IF statement...doesn't work...
--
BostjanTovornik - 2011-09-08
Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the
TWiki consultants if you need timely help. We invite you to
get involved with the community, it is more likely you get community support if you support the open source project!
--
PeterThoeny - 2012-01-23
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.