SQL Query and date_now()

User: "Mike"
New Altair Community Member
Updated by Jocelyn
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:

      <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`&#10;FROM `myTablename` Where`Timestamp` &gt;= ?"/>
        <parameter key="prepare_statement" value="true"/>
        <enumeration key="parameters">
          <parameter key="parameter" value="VARCHAR.%{today}"/>
        </enumeration>
      </operator>
Actually it works fine if I use a static value in the macro definition of %{today}:

    <macros>
      <macro>
        <key>today</key>
        <value>2015-01-13</value>
      </macro>
    </macros>
But it fails when I try to dynamically calculate the current date e.g. as follows:

    <macros>
      <macro>
        <key>today</key>
        <value>date_str_custom(date_now(),"yyyy-MM-dd")</value>
      </macro>
    </macros>
As a result I get all entries of the table instead.

Anyone got an idea?

Cheers, Mike.

Find more posts tagged with