Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Compare dates

Quote Reply
Compare dates

In my LinksSQL every link has two special dates, one is begin_showing, the other is end_showing. That means, the link should only be shown on my page, if I'm in the period between the day of begin_showing and the day of end_showing.

But why does for example this not work: <%if begin_showing eq date%>
If it is written on the screen, both variables are exactly the same, but the result of the if-Statement is false, and it runs over the if and not in it.

In order to compare if the actual day is in this period, I would like to do this (in pseudo-code)

if (date >= begin_showing AND date <= end_showing) OR (if not begin_showing AND if not end_showing)

=> Either it is in the selected period or no begin-and ending-dates are given.

How can I do this?? Thanks, Tina
Quote Reply
Re: [tga] Compare dates In reply to
Firstly, you need <%if begin_showing eq $date%>

For the between two dates, I have something similar. To prevent your complicated condition, try making the default of the first date 0000-00-00 and the default of the second date 3000-00-00. That way you only need
<%if date >= $begin_showing AND date <= $end_showing%> (I think that should work).
Quote Reply
Re: [afinlr] Compare dates In reply to
Thanks for helping, the first with ... eq $... is great!

But the second one, the comparison of dates, does not work.

If i have

this comes to screen:

But this "if" results "true"!
<%if date >= $begin_showing AND date <= $end_showing%>

and I do not understand this!
Quote Reply
Re: [tga] Compare dates In reply to
Hmm, I do seem to remember it took me a bit of time to get this working in the templates. I'm not sure whether the date comparison works. I'm now doing this in a global so I can't compare it to what I had.

Try this:
<%if date > $begin_showing%>

If that still gives true for the example you gave then I think you'll need a global.
Quote Reply
Re: [afinlr] Compare dates In reply to
I'm sorry, but I do not completely understand, what you
mean with solving this problem with a global.

How does this global look like?

Thanks, Tina