on 10-08-2008 10:37 AM
Hi,
I want to write an UDF
I want to pass Date as an String in format yyyymmdd.
I want to convert it to mm/dd/yyyy. & pass new date as o/p/
But there is a possibility that i/p Date may come as blank in that case I want to keep output as blank.
Please help
Hi,
No need of UDF to transform the date format. You can use the standard date function Date Trans.
>>But there is a possibility that i/p Date may come as blank in that case I want to keep output as blank.
Chech if date is Blank using IF condition in yes pass a blak value else pass the date to the standard function and pass the transformed date.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks guys,
I am using this code but get an error
int len;
len = Date.length();
if (len>7)
{
String year = Date.substring (0,4);
String month = Date.substring (4,2);
String day = Date.substring (6,2);
String f = month + "/" + day + "/" + year;
return f;
}
else
{
return Date;
}
--- Here when I run this in test mode I get this exception -
Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: -2] in class com.sap.xi.tf._MM_PSN_EMP_INFO_ method check$[19880517, B1, A1, C1, F1, G1, H1, X1, X1, X1, X1, X1, X1, 07, 5, com.sap.aii.mappingtool.tf3.rt.Context@7ab97403]
Please help.
check ur substring indexing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use the below udf
public String date_conversion(String a,Container container)
{
//write your code here
if(a.length() > 0)
{
String year = a.substring(0,4);
String month = a.substring(5,7);
String day = a.substring(8,10);
String output = month + "/" + day + "/" + year;
return output;
}
else
return " ";
}
jst pass the output of previous udf to the above udf
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.