SQL Query and date_now()
Hi folks,
Following problem: There is a mysql table with a Timestamp column. I want to retrieve all entries of the current day. I was quite optimistic that the following operator would do the trick:
Anyone got an idea?
Cheers, Mike.
Following problem: There is a mysql table with a Timestamp column. I want to retrieve all entries of the current day. I was quite optimistic that the following operator would do the trick:
Actually it works fine if I use a static value in the macro definition of %{today}:
<operator activated="true" class="read_database" compatibility="5.3.015" expanded="true" height="60" name="DB Import" width="90" x="45" y="30">
<parameter key="connection" value="myDBname"/>
<parameter key="query" value="SELECT `ID`,`Timestamp` FROM `myTablename` Where`Timestamp` >= ?"/>
<parameter key="prepare_statement" value="true"/>
<enumeration key="parameters">
<parameter key="parameter" value="VARCHAR.%{today}"/>
</enumeration>
</operator>
But it fails when I try to dynamically calculate the current date e.g. as follows:
<macros>
<macro>
<key>today</key>
<value>2015-01-13</value>
</macro>
</macros>
As a result I get all entries of the table instead.
<macros>
<macro>
<key>today</key>
<value>date_str_custom(date_now(),"yyyy-MM-dd")</value>
</macro>
</macros>
Anyone got an idea?
Cheers, Mike.
Find more posts tagged with
Sort by:
1 - 3 of
31
you cannot use expressions in macros directly. Instead you have to add a "Generate Macro" operator. Example process which logs the current date macro to the console: Regards,
Marco