Getting day of the week out of a date

adamanadaman Member Posts: 17 Contributor II
edited November 2018 in Help
Hey together,
i´m trying to get the day of the week out of a date field. So, after i´m reading the example set, i use the operator "generate attributes".

<operator activated="true" breakpoints="before" class="generate_attributes" compatibility="5.1.000" expanded="true" height="76" name="Generate Attribute" width="90" x="581" y="30">
        <list key="function_descriptions">
          <parameter key="day_of_week" value="date_get(date, DATE_UNIT_DAY)"/>
"use standard constants" is marked as well.

If i put a break bevor the generate attributes the Meta-output is as follows

Role        Name  Type    Statistics                Range                                    Missings
regular date     date length = 5 days [08.04.2011 ; 13.04.2011]      0

If i go on i get the following error:
May 9, 2011 4:55:26 PM SEVERE: Process failed: Generation exception: 'Error during evaluation: Invalid number of arguments for 'date_get', must be 2 or 4.

Is this a bug? or am i doing something wrong?
I´m using 2 arguments as you can see above. I also tried it with a different name instead of date i used date_old but with the same result.


  • IngoRMIngoRM Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Community Manager, RMResearcher, Member, University Professor Posts: 1,751 RM Founder

    well, I tried it myself and it worked fine for me. Which version of RapidMiner do you use?

    However, getting DATE_UNIT_DAY will only deliver the day of month anyway but you are asking for day of week, right? For this purpose, the operator "Date to Numerical" is the best option. See the example below.


    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.006">
      <operator activated="true" class="process" compatibility="5.1.006" expanded="true" name="Process">
        <process expanded="true" height="145" width="738">
          <operator activated="true" class="generate_data" compatibility="5.1.006" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30">
            <parameter key="number_examples" value="1"/>
            <parameter key="number_of_attributes" value="1"/>
          <operator activated="true" class="numerical_to_polynominal" compatibility="5.1.006" expanded="true" height="76" name="Numerical to Polynominal" width="90" x="179" y="30"/>
          <operator activated="true" class="set_data" compatibility="5.1.006" expanded="true" height="76" name="Set Data" width="90" x="313" y="30">
            <parameter key="example_index" value="1"/>
            <parameter key="attribute_name" value="att1"/>
            <parameter key="value" value="19.08.2010"/>
            <list key="additional_values"/>
          <operator activated="true" class="nominal_to_date" compatibility="5.1.006" expanded="true" height="76" name="Nominal to Date" width="90" x="447" y="30">
            <parameter key="attribute_name" value="att1"/>
            <parameter key="date_format" value="dd.MM.yyyy"/>
          <operator activated="true" class="date_to_numerical" compatibility="5.1.006" expanded="true" height="76" name="Date to Numerical" width="90" x="581" y="30">
            <parameter key="attribute_name" value="att1"/>
            <parameter key="time_unit" value="day"/>
            <parameter key="day_relative_to" value="week"/>
            <parameter key="keep_old_attribute" value="true"/>
          <connect from_op="Generate Data" from_port="output" to_op="Numerical to Polynominal" to_port="example set input"/>
          <connect from_op="Numerical to Polynominal" from_port="example set output" to_op="Set Data" to_port="example set input"/>
          <connect from_op="Set Data" from_port="example set output" to_op="Nominal to Date" to_port="example set input"/>
          <connect from_op="Nominal to Date" from_port="example set output" to_op="Date to Numerical" to_port="example set input"/>
          <connect from_op="Date to Numerical" 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"/>
  • adamanadaman Member Posts: 17 Contributor II
    Thank you,

    yes you are absolutly right, this is what i need :-)
    Now it works and i got the day_of_week thanks again

    Still the other transformation doesn´t work. I´m using RapidMiner 5.1.000

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering

    that was a bug which has already been fixed. I suggest updating RapidMiner to the latest version.

Sign In or Register to comment.