🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

date to str problem

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



Find more posts tagged with

Sort by:
1 - 1 of 11
    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.

    Cheers,
    Martin

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.4.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <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>
            <list key="set_additional_roles"/>
          </operator>
          <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;)"/>
            </list>
          </operator>
          <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"/>
        </process>
      </operator>
    </process>