US and Worldwide: +1 (866) 660-7555
Results 1 to 6 of 6

Thread: string to date

  1. #1

    Default string to date

    i know there are a lot of threads
    but i didnt find an answear

    i need to transform a string like this
    20010223 into a date format like this 2001-02-03 (yyyy-MM-dd)


    with a javascript step i worked with string and now i have a string like this 2001-02-03, but is a string, and i need a data format...


    the step next of the JSValue is a SelectValues step...

    any ideas?




    thanks

  2. #2
    Join Date
    Nov 1999
    Posts
    9,687

    Default

    I'm sure we have a sample doing just that.

    Anyway...

    Code:
    var dateField = dateField.Clone().str2dat("yyyyMMdd").getDate();
    Last edited by MattCasters; 05-28-2007 at 12:26 PM. Reason: typo
    Matt Casters, Chief Data Integration
    Pentaho, Open Source Business Intelligence
    http://www.pentaho.org -- mcasters@pentaho.org

    Author of the book Pentaho Kettle Solutions by Wiley. Also available as e-Book and on the Kindle reading applications (iPhone, iPad, Android, Kindle devices, ...)

    Join us on IRC server Freenode.net, channel ##pentaho

  3. #3

    Default

    i found the sample
    but the sample is date.to.string.conversion


    my problem is:

    i can operate on the string with a javascript
    in fact i transformed 20010123 into 2001-01-03 but is always a string

    the step next the JavaScriptValue is SelectValue

    in the Meta-Data menu of SelectValue step i canghed the type into Date
    but nothign...





    if any ideas...please... i'm goin nut....

    thanks

  4. #4

    Default i'm close to the solution...

    now i succeded to convert my string to a date

    the string was like

    20060116

    i transformed into this date format
    2006/01/16 00:00:00:000
    with this function
    date=string.str2dat("yyyyMMdd")

    problem is that i need it in this format
    2006-01-16



    i neeeeeed a solution... please help me...

  5. #5
    Join Date
    Nov 1999
    Posts
    9,687

    Default Oh please...

    A date doesn't have a format.
    If you want to apply a format, convert it back to a string...
    Matt Casters, Chief Data Integration
    Pentaho, Open Source Business Intelligence
    http://www.pentaho.org -- mcasters@pentaho.org

    Author of the book Pentaho Kettle Solutions by Wiley. Also available as e-Book and on the Kindle reading applications (iPhone, iPad, Android, Kindle devices, ...)

    Join us on IRC server Freenode.net, channel ##pentaho

  6. #6

    Default

    to a string?

    no way man... it's a DATE, not a string...


    any way i solved... finally free form the DATE problem...


    now i have a progressive field ti implement...



    thanks for all....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •