on 04-05-2012 9:39 AM
hi all,
I have to insert date and time to oracle db from pi and it has a format
mm/dd/yyyy hh:mm:ss am
or
mm/dd/yyyy hh:mm:ss pm
how can i achieve this in PI .how can i get time in 12 hr format...
thanks,
sahana
thanks all,i solved the issue...
no need of udf or complex mapping
it can be achieved in TO_DATE() function passing current date as MM/dd/yyyy HH:mm:ss a
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can try UDF with few lines of coding. This is another simpler approach.
Note: Create method with return String type and pass your sender date as input parameter
String input = "April 5, 2012 1:14 AM";
DateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
Date date;
// Parse the date
try {
date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).parse(input);
} catch(ParseException pe) {
pe.getStackTrace();
}
hi sahana,
ur
mm/dd/yyyy hh:mm:ss -> 05/04/20112 23:57:47,06/04/2012 00:01:15
o/p should be:
mm/dd/yyyy hh:mm:ss am -> 06/04/2012 00:01:15 AM
or
mm/dd/yyyy hh:mm:ss pm -> 05/04/20112 11:57:47 PM
is it correct?
if correct , once use below logic :
in currecnt date , u need to split the value by using substring(11,2) means hours only if that value is greather than 12 then subtract the value with 12 then concat total string , else pass the same value with concat spaceAM thats all.
if you want to use same date value in mutipl times in target structure, we need to use "useOne AsMany" funtion of the Node Function group and u cen use before target field .
ref below link for ex how to use standard function "useOne AsMany" :
http://www.saptechnical.com/Tutorials/XI/NodeFunctions/Page5.htm
Message was edited by: solasu bhavanisankar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try with this little UDF (assuming that input is your input variable):
Date date = DateFormat.parse(input);
DateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
return df.format(date);
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.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
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.