Options

date_diff() output?

ybrittybritt Member Posts: 5 Contributor II
edited November 2018 in Help
Hi,

In what unit does the function date_diff() return the time difference and how do I convert the result (a very large integer) to, e.g. hours?

Thanks in advance!

Answers

  • Options
    haddockhaddock Member Posts: 849 Maven
    Hi,

    You should read the help section for  "Date to Numerical"  and "Generate Attribute" operators, and the resources listed under "help".
  • Options
    awchisholmawchisholm RapidMiner Certified Expert, Member Posts: 458 Unicorn
    Hello

    A little experiment reveals that the difference between 2 dates is in milliseconds. See the example below.

    regards,

    Andrew

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.001">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.1.001" expanded="true" name="Process">
        <process expanded="true" height="341" width="815">
          <operator activated="true" class="generate_data" compatibility="5.1.001" expanded="true" height="60" name="Generate Data" width="90" x="45" y="75">
            <parameter key="number_examples" value="10"/>
          </operator>
          <operator activated="true" class="select_attributes" compatibility="5.1.001" expanded="true" height="76" name="Select Attributes" width="90" x="179" y="75">
            <parameter key="invert_selection" value="true"/>
            <parameter key="include_special_attributes" value="true"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="5.1.001" expanded="true" height="76" name="Generate Attributes" width="90" x="313" y="75">
            <list key="function_descriptions">
              <parameter key="Now" value="date_now()"/>
            </list>
          </operator>
          <operator activated="true" class="delay" compatibility="5.1.001" expanded="true" height="76" name="Delay" width="90" x="447" y="75">
            <parameter key="delay" value="fixed"/>
            <parameter key="delay_amount" value="1234"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="5.1.001" expanded="true" height="76" name="Generate Attributes (2)" width="90" x="581" y="75">
            <list key="function_descriptions">
              <parameter key="NowPlus" value="date_now()"/>
              <parameter key="diff" value="date_diff(Now,NowPlus)"/>
            </list>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Select Attributes" to_port="example set input"/>
          <connect from_op="Select Attributes" from_port="example set output" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" from_port="example set output" to_op="Delay" to_port="through 1"/>
          <connect from_op="Delay" from_port="through 1" to_op="Generate Attributes (2)" to_port="example set input"/>
          <connect from_op="Generate Attributes (2)" from_port="example set output" 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>
  • Options
    ybrittybritt Member Posts: 5 Contributor II
    Good morning!

    Thanks both of you for pointing me in the right direction
Sign In or Register to comment.