can i increment date

gritsaygritsay Member, University Professor Posts: 12  University Professor
edited November 2018 in Help
Hi everybody! i have a macro with date in my process. How i can increment macro in 1 day? For example i have a date = 10.01.2013. i need date+1 = 11.01.2013 how i can do it?

Alex.

Answers

  • Marco_BoeckMarco_Boeck Team Lead Software Engineering Administrator, Moderator, Employee, Member, University Professor Posts: 1,850   RM Engineering
    Hi,

    you can use the Generate Macro operator for that. Have a look at the following example process.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.0.009">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.0.009" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="retrieve" compatibility="6.0.009" expanded="true" height="60" name="Retrieve Iris" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Samples/data/Iris"/>
          </operator>
          <operator activated="true" class="set_macro" compatibility="6.0.009" expanded="true" height="76" name="Set Macro" width="90" x="179" y="30">
            <parameter key="macro" value="date"/>
            <parameter key="value" value="22.07.2014"/>
          </operator>
          <operator activated="true" class="generate_macro" compatibility="6.0.009" expanded="true" height="76" name="Generate Macro" width="90" x="313" y="30">
            <list key="function_descriptions">
              <parameter key="date" value="date_add(date_parse_custom(&quot;%{date}&quot;, &quot;dd.MM.yyyy&quot;, &quot;en&quot;), 1, DATE_UNIT_DAY)"/>
            </list>
          </operator>
          <operator activated="true" class="print_to_console" compatibility="6.0.009" expanded="true" height="76" name="Print to Console" width="90" x="447" y="30">
            <parameter key="log_value" value="%{date}"/>
          </operator>
          <connect from_op="Retrieve Iris" from_port="output" to_op="Set Macro" to_port="through 1"/>
          <connect from_op="Set Macro" from_port="through 1" to_op="Generate Macro" to_port="through 1"/>
          <connect from_op="Generate Macro" from_port="through 1" to_op="Print to Console" to_port="through 1"/>
          <connect from_op="Print to Console" from_port="through 1" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    Regards,
    Marco
  • ravishvkravishvk Member Posts: 2 Contributor I
    This macro is not working in Rapidminer 9.3.0. Getting expression evaluation error. Invalid_argument.date.
  • ravishvkravishvk Member Posts: 2 Contributor I
    Looks like by removing double quote from %{date} 
    as mentioned here, it's working as expected for Rapidminer version 9.3.

    date_add(date_parse_custom(%{date}, "dd.MM.yyyy", "en"), 1, DATE_UNIT_DAY)
    Tghadially
Sign In or Register to comment.