One Star

[resolved] Get day of the Week in Talend

Hi,
I need to populate the day of week (example : "Tue" for Tuesday into the database string data type column by using the tmap.
Can anyone please suggest me?
Thanks!
1 ACCEPTED SOLUTION

Accepted Solutions
One Star

Re: [resolved] Get day of the Week in Talend

Thank you Shong!
My problem resolved.
Var.var1==0?"SUN": (Var.var1==1?"MON": (Var.var1==2?"TUE": (Var.var1==3?"WED": (Var.var1==4?"THU": (Var.var1==5?"FRI":"SAT")))))
8 REPLIES
Community Manager

Re: [resolved] Get day of the Week in Talend

Hi
There is a built-in function TalendDate.getPartOfDate(String date_part, Date date) returns the part of date, includes DAY_OF_WEEK, this function returns an int data, so, you can call this function to get the part of week and convert it text string like this:

expression of var1:
TalendDate.getPartOfDate("DAY_OF_WEEK", row1.newColumn) 

expression of newColumn
Var.var1==0?"Sun": (Var.var1==1?"Mon": (Var.var1==2?"Tue": (Var.var1==3?"Wed": (Var.var1==4?"Thu": (Var.var1==5?"Fri":"Sat")))))


Hope this helps you.
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Get day of the Week in Talend

Hi Shong,
I did used the expression as provided by you and getting the error.
ORA-14400: inserted partition key does not map to any partition
Expressions used
TalendDate.getPartOfDate("DAY_OF_WEEK",msp_dly_copyright_file.WK_DAY)
Var.var1==0?"Sun": (Var.var1==1?"Mon": (Var.var1==2?"Tue": (Var.var1==3?"Wed": (Var.var1==4?"Thu": (Var.var1==5?"Fri":"Sat")))))



Please correct me if I'm wrong.
Thanks,
Yugandhar
One Star

Re: [resolved] Get day of the Week in Talend

Thank you Shong!
My problem resolved.
Var.var1==0?"SUN": (Var.var1==1?"MON": (Var.var1==2?"TUE": (Var.var1==3?"WED": (Var.var1==4?"THU": (Var.var1==5?"FRI":"SAT")))))
Community Manager

Re: [resolved] Get day of the Week in Talend

Great! thanks for your feedback.
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Get day of the Week in Talend

Hi Shong,
I'm encountering one more problem while loading the WK_DAY into the target table.
From my source I'm not getting any date values.Only thing I need to do is whenever the job gets execute it should populate the day of the week into the column.
My problem is when I execute the job on Thu (Thursday) week day the table is getting popualted as "SUN" (Sunday)
Can you please correct me if anything is wrong.
TalendDate.getPartOfDate("DAY_OF_WEEK",row3.WK_DAY)
Var.var1==0?"SUN": (Var.var1==1?"MON": (Var.var1==2?"TUE": (Var.var1==3?"WED": (Var.var1==4?"THU": (Var.var1==5?"FRI":"SAT")))))
Talend screenshot

Database table screenshot


Thanks,
Yugandhar
Community Manager

Re: [resolved] Get day of the Week in Talend

Hi
If the date does not come from the input data,  you can use TalendDate.getCurrentDate() to get the current date, so change the expression to:
TalendDate.getPartOfDate("DAY_OF_WEEK",TalendDate.getCurrentDate()) 
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Get day of the Week in Talend

Hi Shong,
I'm using the below expression in the talend tmap and getting the below error(cannot convert int  to string)
TalendDate.getPartOfDate("DAY_OF_WEEK",TalendDate.getCurrentDate())
Can you please let me know if anything is wrong




Thanks
One Star

Re: [resolved] Get day of the Week in Talend

Thank Shong!
I did implemented the expression and it is working fine.
Please ignore the above message.