Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I was trying to compare two dates as follows (and with a few minor variants):
Code: Select all
<cms:if "<cms:date k_page_date format='Y-m-d' />" ge "<cms:date format='Y-m-d' />" >

with no success, so ended up using this:
Code: Select all
<cms:set compare_today="<cms:date format='Y-m-d'/>" />
<cms:set compare_event_date="<cms:date k_page_date format='Y-m-d' />" />
<cms:if compare_event_date ge compare_today >

which works OK.

It would seem preferable to do this in a single line of code if possible ... or isn't it?
Hi Potato,

The behaviour you observed has to do with the way language parsers are constructed.
To put it in simple terms, the LHS (Left Hand Side) of an expression has to be a variable.
The RHS (Right Hand Side) may be a variable or a constant or another expression.

With that understood, you can see that you were supplying an expression as the LHS of your statement
<cms:if "<cms:date k_page_date format='Y-m-d' />" ge "<cms:date format='Y-m-d' />" >

The right way could be first placing the result of the expression into a variable and then using it as LHS:
Code: Select all
<cms:set compare_event_date="<cms:date k_page_date format='Y-m-d' />" />
<cms:if compare_event_date ge "<cms:date format='Y-m-d' />" >
   ...
</cms:if>

Sorry for all that developer-parlance :)
Hope this helps.
thanks KK - crystal clear! (were you ever a teacher? you have a gift for explaining things!)
3 posts Page 1 of 1