on 03-28-2012 1:56 PM
HI Folks
I need a UDF which will insert the date in datetimeformat in oracle database via jdbc
my input is say - 20120309 ( datab coming from idoc ) concatenated with constant ( 12.00.00 )
my input to udf will be 20120309 12.00.00 and my output should be 09-MAR-12 12.00.00
please help me at the earliest i tried date trans function but not working
Thanks
Ninad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ninad,
check this link. this could be achieved using mapping itself. UDF is not required.
http://www.saptechnical.com/Tips/XI/Date/Oracle.htm
-Deepak
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ninad,
You can try this code -
make sure you import following in the import tab of udf -
java.text.SimpleDateFormat
java.uti.Date ;
sample code -
public String concatDate(String dateIdoc, String time, Container container) throws StreamTransformationException{
String oraDate = "" ;
Date date ;
SimpleDateFormat sdfSource = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat sdfDestination = new SimpleDateFormat("dd-MMM-yyyy");
try {
date = sdfSource.parse(dateIdoc);
}catch (Exception e)
{
// your exception logic
}
oraDate= sdfDestination.format(date);
oraDate= oraDate+ " " +time ; //String time can be constant as per your requirement or if you get it from idoc you can use it as input to udf
return oraDate;
}
- Piyusha Deshpande
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ninad,
There are few nice formatting examples here:
http://www.exampledepot.com/egs/java.text/formatdate.html
Try the following code in a UDF (assuming that your input parameter is called input😞
Format formatter;
Date date = DateFormat.parse(input);
formatter = new SimpleDateFormat("yy-MMM-dd HH.mm.ss");
String s = formatter.format(date);
return s;
Hope this helps,
Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try this: use datetrans method. input datab to it. double click it - set both input and output date formats. MMM shall give MAR for example. this will output date in req format.
then take time and concatenate it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.