Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Integer to date conversion does not work

  1. #1

    Default Integer to date conversion does not work

    Hi all,

    I want to do something very simple: I get the a date from my database as Integer in the format yyyyMMdd e.g. 20171213 for today's date. Now I want to convert that to a real date with the Select Values step and the meta data tab. But for some reason the result is always 19700101 (see attached transformation)

    I must be missing something very stupid here ....
    Thanks!

    Max

    tr_string_to_date_2.ktr
    PDI 7
    Postgres
    Windows 7

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    You can't convert from Integer to Date directly.
    Cast the Integer to String in your SELECT statement and you'll be fine.
    So long, and thanks for all the fish.

  3. #3

    Default

    In the attachment you can see that I am actually using a Data Grid as input (data type is Integer). I have also tried it with data type String or to use a Select step in between to convert from Integer to String before converting from String to Date but none of them worked.
    PDI 7
    Postgres
    Windows 7

  4. #4
    Join Date
    Sep 2010
    Posts
    18

    Default

    Quote Originally Posted by Bobse View Post
    In the attachment you can see that I am actually using a Data Grid as input (data type is Integer). I have also tried it with data type String or to use a Select step in between to convert from Integer to String before converting from String to Date but none of them worked.
    I have used it many many times and it works it do it String to Date with format specified.

  5. #5

    Default

    Ah, got it. What threw me off is that it does not show the date in a 'proper' date format in the preview tab so by just looking at that you cannot tell that it actually converted it to a date type. But when using the context menu 'Output fields' it shows as date and a following Calculator step to calculate the days between two of these days is actually also working properly.
    PDI 7
    Postgres
    Windows 7

  6. #6
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Quote Originally Posted by Bobse View Post
    I have also tried it with data type String ... but none of them worked.
    That's not what I see.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.