date to str problem

blatooblatoo Member Posts: 32 Contributor II
edited November 2018 in Help
Hello all,

I have a problem with "date_str()", and I can not find more detailed description and example about it.

In the help:

Date to String (date_str(date1, DATE_FORMAT_CONSTANT, DATE_SHOW_CONSTANT)): Changes a date to a string using the specified format; example: date_str(A, DATE_FULL, DATE_SHOW_DATE_AND_TIME)

My Question is:

1. Where can I find the values of DATE_FORMAT_CONSTANT and DATE_SHOW_CONSTANT?

2. If I want turn "Jul 08, 2012" to "2012-07-08", how can I set the right parameter?

Thanks very much for the concentration!


  • Options
    MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,510 RM Data Scientist
    Hi there!

    date_str is to convert a date into a string. You want to do it vice verse. Thus date

    date_parse_custom(DateAtt,"MMM dd, yyyy")
    For the formatting i recommend http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html . I always get confused by M and m. attached is an example process.


    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.4.000">
      <operator activated="true" class="process" compatibility="6.4.000" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="generate_data_user_specification" compatibility="6.4.000" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="45" y="30">
            <list key="attribute_values">
              <parameter key="DateAtt" value="&quot;Jul 08, 2012&quot;"/>
            <list key="set_additional_roles"/>
          <operator activated="true" class="generate_attributes" compatibility="6.4.000" expanded="true" height="76" name="Generate Attributes" width="90" x="246" y="30">
            <list key="function_descriptions">
              <parameter key="NewDateAtt" value="date_parse_custom(DateAtt,&quot;MMM dd, yyyy&quot;)"/>
          <connect from_op="Generate Data by User Specification" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" 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"/>

    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
Sign In or Register to comment.