One Star

[resolved] Extract year & Month from Date

Hi all,
I have a problem.. I want to extract Year and month from date. I tried with this method :
row1.var.getYear()
row1.var.getMonth()
But it doesn't work
For exemple, my date is "2006-01-01" , with tLogRow, when i do
getMonth() i found in the output "0"
for "2006-02-01" i found "1"
for "2006-03-01" i found 2
getYear() ---> i found 106 in the output
getDay()---> i found 0

Why this method doesn't work ? Is there an other method for extraction ?
Thanks in advance,

Rajaa
2 REPLIES
One Star

Re: [resolved] Extract year & Month from Date

Hi Raja,

Use below Methods:
Extract Year-->> TalendDate.formatDate("yyyy",row1.Date)
Extract Month-->> TalendDate.formatDate("MM",row1.Date)
I hope Above logics are work fine..
Thanks,
kumar
One Star

Re: [resolved] Extract year & Month from Date

Hi Kumar,
Thank you so much for the help, it works Smiley Happy