
Anonymous
Not applicable
2015-02-04
07:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[resolved] extract year from date type variable
Hello All,
I need to convert Start_Date Column which is date datatype ex: "2012-12-26" to Start_Date_Key as 20121226 INT Datatype.
I can easily do it in SSIS with the expression (YEAR((DT_DBDATE)START_DATE) * 10000) + (MONTH((DT_DBDATE)START_DATE) * 100) +DAY((DT_DBDATE)START_DATE).
How to achieve the above solution in TOS. I tried and no result came.
Please help.
Thanks ---> D
I need to convert Start_Date Column which is date datatype ex: "2012-12-26" to Start_Date_Key as 20121226 INT Datatype.
I can easily do it in SSIS with the expression (YEAR((DT_DBDATE)START_DATE) * 10000) + (MONTH((DT_DBDATE)START_DATE) * 100) +DAY((DT_DBDATE)START_DATE).
How to achieve the above solution in TOS. I tried and no result came.
Please help.
Thanks ---> D
801 Views
- « Previous Replies
-
- 1
- 2
- Next Replies »
1 Solution
Accepted Solutions

Anonymous
Not applicable
2015-02-04
11:19 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
In Talend, you can convert the data with date type to an int data with this expression:
source input--main(row1)--tMap--tLogRow
Shong
In Talend, you can convert the data with date type to an int data with this expression:
source input--main(row1)--tMap--tLogRow
TalendDate.getPartOfDate("YEAR",row1.YouDateColumnName)*10000+(TalendDate.getPartOfDate("MONTH",row1.YouDateColumnName)+1)*100+TalendDate.getPartOfDate("DAY_OF_MONTH",row1.YouDateColumnName)
Shong
735 Views
11 Replies

Anonymous
Not applicable
2015-02-04
11:19 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
In Talend, you can convert the data with date type to an int data with this expression:
source input--main(row1)--tMap--tLogRow
Shong
In Talend, you can convert the data with date type to an int data with this expression:
source input--main(row1)--tMap--tLogRow
TalendDate.getPartOfDate("YEAR",row1.YouDateColumnName)*10000+(TalendDate.getPartOfDate("MONTH",row1.YouDateColumnName)+1)*100+TalendDate.getPartOfDate("DAY_OF_MONTH",row1.YouDateColumnName)
Shong
736 Views

Anonymous
Not applicable
2015-02-05
07:03 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Shong,
I really appreciate your answer.
i worked with the same code yesterday and executed the "Test" button in tmap Component to check for the result, but it is showing error!!cannot be resolved. Given default value to my date column.
When i run my job, expected values are dumped to my DB Table. thats cooool.
i request you to suggest on how to post a new topic in talend forum instead of reply to post which exists already.
Thanks---->D
I really appreciate your answer.
i worked with the same code yesterday and executed the "Test" button in tmap Component to check for the result, but it is showing error!!cannot be resolved. Given default value to my date column.
When i run my job, expected values are dumped to my DB Table. thats cooool.
i request you to suggest on how to post a new topic in talend forum instead of reply to post which exists already.
Thanks---->D
734 Views

Anonymous
Not applicable
2015-02-05
07:58 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Shong,
I have a similar doubt. i can do easily in SSIS. Confused to do the same thing in TOS as it involved JAVA.
i need to replicate 3 zero's (000) and add 2nd column which will be 004, same for 3rd column..003
finally it should look like 1st + 2nd +3rd column : 20140203004003
waiting for your early reply
Thanks---->D
I have a similar doubt. i can do easily in SSIS. Confused to do the same thing in TOS as it involved JAVA.
i need to replicate 3 zero's (000) and add 2nd column which will be 004, same for 3rd column..003
finally it should look like 1st + 2nd +3rd column : 20140203004003
waiting for your early reply
Thanks---->D
734 Views

Anonymous
Not applicable
2015-02-05
08:04 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I don't understand your last requirement, do you just want to append "003" to the int data? For example:
"yourLastIntData"+"003"
Can you please explain it with more details?
BR
Shong
I don't understand your last requirement, do you just want to append "003" to the int data? For example:
"yourLastIntData"+"003"
Can you please explain it with more details?
BR
Shong
734 Views

Anonymous
Not applicable
2015-02-06
12:39 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Actually not able to add screenshot.
here are my three columns and their values.
Start_Date(Long) | Unit(integer) | Source(integer)
20140203| 4| 3
Outcome should be concatenating all 3 columns and for 2nd and 3rd we need to supply it as 3 digits like "004" and "003"
Finally it should be "KEY"(long)=20140203004003
Thanks--->D
Actually not able to add screenshot.
here are my three columns and their values.
Start_Date(Long) | Unit(integer) | Source(integer)
20140203| 4| 3
Outcome should be concatenating all 3 columns and for 2nd and 3rd we need to supply it as 3 digits like "004" and "003"
Finally it should be "KEY"(long)=20140203004003
Thanks--->D
734 Views

Anonymous
Not applicable
2015-02-08
04:05 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this expression:
Long.parseLong(""+row1.c1+String.format("%03d",row1.c2)+String.format("%03d",row1.c3)
734 Views

Anonymous
Not applicable
2015-02-09
07:40 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's perfecto shong...
734 Views

Anonymous
Not applicable
2015-02-09
07:57 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Shong.
I have a string like "03-12-2012" in "MM-dd-yyyy" format.
i need to get result as "20120312" which is ""yyyyMMdd" format.
i tried with right and left string functions to get "yyyyMM" and stuck in getting "dd".
Do i need to create routine for that? or is there any built in function equivalent to SubString() in TOS?
Thanks--->D
I have a string like "03-12-2012" in "MM-dd-yyyy" format.
i need to get result as "20120312" which is ""yyyyMMdd" format.
i tried with right and left string functions to get "yyyyMM" and stuck in getting "dd".
Do i need to create routine for that? or is there any built in function equivalent to SubString() in TOS?
Thanks--->D
734 Views

Contributor II
2015-02-09
08:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
new SimpleDateFormat("yyyyMMdd").format(newSimpleDateFormat("MM-dd-yyyy").parse(row1.date))
734 Views

- « Previous Replies
-
- 1
- 2
- Next Replies »