Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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... 0683p000009MACn.png
looking forward for a quick reply......
Labels (2)
6 Replies
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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:MI 0683p000009M9p6.pngS is the format i want it to be dd-mm-yyyy

regards
alevy
Specialist
Specialist

I asked https://community.talend.com/t5/Archive/SCD-ways-of-loading-a-fact-and-dimensional-table-at-the-same... 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 0683p000009MPcz.png.
Anonymous
Not applicable
Author

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

}
Anonymous
Not applicable
Author

Any help in regard to this forum will be appreciated

ThanQ
alevy
Specialist
Specialist

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".