• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] String to date change

#1 2012-05-11 13:15:49

djugal
Member
Registered: 2011-06-16
Posts: 229
Website

[resolved] String to date change

Hi,
i have a conversion to make from string to date

my input string comes in any format numeric or any "yyyy-MM-dd HH:mm:ss" or "yyyy-MM-dd" "MM-dd-yyyy" etc

in my tmap filter i filter out the column for invalid data using
TalendDate.isDate(row16.string1,"yyyy-MM-dd HH:mm:ss") or
(TalendDate.isDate(row16.dtu,"yyyy-MM-dd")

in the tmap expression for the output date column i put
!Relational.ISNULL(row1.dtu)?
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row1.dtu)
:null

this works for "yyyy-MM-dd HH:mm:ss" but not for "yyyy-MM-dd"

i get the error unparsable date "2012-05-10"


any help would be appreciated

regards,
djugal

Offline

#2 2012-05-11 22:21:37

tmaurin
Member
Company: Cosmos Consulting
Registered: 2011-05-17
Posts: 30
Website

Re: [resolved] String to date change

Your date "2012-05-10" doesn't correspont to patten "yyyy-MM-dd HH:mm:ss"

try somthing like this :

!Relational.ISNULL(row1.dtu)?
   row1.dtu.length() == 19 ?
   TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row1.dtu)
   : TalendDate.parseDate("yyyy-MM-dd",row1.dtu)
:null


Thomas Maurin
Chef de projet décisionnel
Cosmos Consulting
http://www.cosmos-consulting.fr

Offline

#3 2012-05-12 04:59:16

djugal
Member
Registered: 2011-06-16
Posts: 229
Website

Re: [resolved] String to date change

Thanks

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] String to date change

Board footer

Powered by FluxBB