This question about Using an extension: Closed unanswered
How can I compare dates in if and query statements?
I desperately try to compare two dates in an IF - statement to achieve an action accordingly, wheras one is in a variable.
Used time fomat in variable is "22 Apr 2013"
Variable is called %DATUM% and is defined by using a date stored in a meta preference data
Now I try to get a result depending if a date is in a certain timeframe.
Example: if %DATUM% is between now and the next two days I want to get result A
%IF{"' '%DATUM%' > now AND 'now + 2*86400' " then="A"}%
86400 is one day in seconds
I tried many things using CALC, d2n and combinations of these. What surprisingly works is
%IF{"' '%DATUM%' > now " then="A"}%
If somebody could resolve this issue I would be very happy.
--
ThomasSchmidt - 23 Apr 2013
- Set DATUM1 = 23 Apr 2013
- Set DATUM2 = 24 Apr 2013
- Set DATUM3 = 25 Apr 2013
- Set DATUM4 = 26 Apr 2013
While that may not be perfect (view wiki text for details), I hope it points you in the right direction.
I think your final 'working' example is in fact broken.
--
JulianLevens - 23 Apr 2013
Thx, but It doesn't work. I use it within DBQuery format string such as:
%IF{"d2n('$expand(preferences.due)') > d2n('%DATE%') AND d2n('$expand(preferences.due)') <= %CALC{"$TIMEADD($TIME(),2,day)"}%" then="A"}%
while due is a META::PREFERENCE variable
Maybe it is a matter of how DBQUERY works.
Still amazing is that when I use %IF{"'$expand(preferences.due)' > d2n('%DATE%') then="A"}%
It Works!
--
ThomasSchmidt - 23 Apr 2013
Sorry but I don't have a quick answer, and I don't know DBQUERY.
I do wonder if embedding %IF inside a %DBQUERY might be an issue. I'm not sure if %IF understands $expand even though DBQUERY does.
--
JulianLevens - 23 Apr 2013