[ic] TO_DAYS(now())

Russell Mann interchange-users@icdevgroup.org
Mon Jul 29 16:02:00 2002


Hello List,

Is the sql command TO_DAYS(now()) supported in Interchange?  I have a query
designed like this:

[query
prefix=pre
list=1
type=list
st=db
sql=|
SELECT * FROM table_name
WHERE TO_DAYS(NOW()) - TO_DAYS(date) >= 0
ORDER BY date DESC
LIMIT 4
|
]

This is designed to get the most recent four entries from today or earlier,
based on the "date" field.  This works just fine by running the query
straight to mySQL, and it works fine in PHP, but in Interchange it produces
this error:

[29/July/2002:12:44:05 -0700] Query rerouted from table products failed: Bad
SQL statement: Parse error near NOW()) - TO_DAYS(date) >= 0
> ORDER BY date DESC
> LIMIT 4 at /usr/lib/interchange/lib/Vend/Scan.pm line 586.
>
> Query was: SELECT * FROM table_name
> WHERE TO_DAYS(NOW()) - TO_DAYS(date) >= 0
> ORDER BY date DESC
> LIMIT 4 at /usr/lib/interchange/lib/Vend/Table/DBI.pm line 1601
>
> Query was: SELECT * FROM table_name
> WHERE TO_DAYS(NOW()) - TO_DAYS(date) >= 0
> ORDER BY date DESC
> LIMIT 4


I've tried replacing the now() command with this to see if that was the
problem:
[value name=now set="[tag time]%Y-%m-%d[/tag]"]
But it still errors out at the same spot, just replacing now() in the error,
with the current date.


Any ideas on this would be helpful.  The list archives don't have anything
on TO_DAYS, and it's pointless to search for now() because the search strips
the parenthesis.

Thanks,

Russell