One Star

Is is there a way to get the weekday?

Hi,
is there a way to get the weekday by Talend functions? And can I get it formated locale (this case in pt-br)?
Thanks.
5 REPLIES
One Star

Re: Is is there a way to get the weekday?

like, you want to know what the current day of the week is? or what day of the week a certain date falls on?
if you hit CTRL-Space, in a field you can input formulas/code into, it will pop down a list of available variables and functions (see attached pic)
here are some, various, talend date formula options:
TalendDate.getCurrentDate()
TalendDate.getDate("CCYY-MM-DD hh:mm:ss")
TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",myDate)
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss","")

and what does pt-br mean?
there look to be two date functions that deal with Locale:
TalendDate.formatDateLocale("yyyy-MM-dd HH:mm:ss",myDate,"EN")
TalendDate.parseDateLocale("yyyy-MM-dd HH:mm:ss","","EN")

http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
One Star

Re: Is is there a way to get the weekday?

I tried these functions, but havent found one that match my needs....
I want to get the current weekday (ex. Friday), but in portuguese (ex. Sexta).
I think it would be like: TalendDate.formatDateLocale("Weekday",TalendDate.getDate("Weekday")
,"PT"). Is this possible? How is the correct command?
One Star

Re: Is is there a way to get the weekday?

you were using the wrong name/code for weekday (see "Date and Time Patterns" table in http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html)
also, TalendDate.getDate() returns a string value, and you need to return a date value to be able to use the formatDateLocale formula
for the abbreviated name
TalendDate.formatDateLocale("E",TalendDate.getCurrentDate(),"PT")

for the full name
TalendDate.formatDateLocale("EEEE",TalendDate.getCurrentDate(),"PT")
One Star

Re: Is is there a way to get the weekday?

Thanks, It worked great.
One Star

Re: Is is there a way to get the weekday?

Integer.toString (TalendDate.getPartOfDate("DAY_OF_WEEK", TalendDate.getCurrentDate() )-1)