One Star

TRUNC() FUNCTION

HIII...


i want to trunc() funtion on one of my columns in TMAP how do i call a routine on my col...
i mean is their any system routine which could handle this function........



Thanx in advance...Smiley Happy
looking forward for a quick reply......
6 REPLIES
Community Manager

Re: TRUNC() FUNCTION

Hi
Do you want to use this function handle Date or numeric data? Can you give us an example to explain your request?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: TRUNC() FUNCTION

yes.... its to handle a date...

its like i have column which contains date and time i want only date not time and round it... (as trunc does it)

DD-Mon-YYYY HH:MISmiley FrustratedS is the format i want it to be dd-mm-yyyy

regards
Seven Stars

Re: TRUNC() FUNCTION

I asked here for such a method to be added to TalendDate, which was supposed to be in v4.2.0, but it hasn't been done yet Smiley Sad.
One Star

Re: TRUNC() FUNCTION

Hi,
The problem is after truncating the date ,using Format or SimpleDateFormat in java,returning that date make again concatination of 00:00:00.The above java code is returning string,in date case we required string to date conversion again........
The code mention below returns the date but with concatination of 00:00:00 by itself....

public Date returnDate(Date dateTime)
{
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd/MM/yyyy");

Format formatter=new SimpleDateFormat("dd/MM/yyyy");
String sample=formatter.format(dateTime);
try{
Date d=simpleDateFormat.parse(sample);
return d; //return date againwith hh:mm:ss concatination ,so no use of this function
}
catch (Exception e) {
e.printStackTrace();
}
return null;//as it is successful it will not return null ,it return d

}
One Star

Re: TRUNC() FUNCTION

Any help in regard to this forum will be appreciated

ThanQ
Seven Stars

Re: TRUNC() FUNCTION

If you want a Date object as your output but with the time set to midnight, you can do it yourself with TalendDate.parseDate("dd/MM/yyyy",TalendDate.formatDate("dd/MM/yyyy",row1.newColumn)).
If you want a String object, you only need TalendDate.formatDate("dd-MM-yyyy",row1.newColumn).
And if you only want to output your Date to a file in the right format, just set the Date Pattern of the output schema to "dd-MM-yyyy".