Skip to Content

Mapping logic to convert Time format from 24 hours to 12 hours format in PI/XI

I have seen in many Blogs  where people asking about several converting time format  from 24 hours to 12hours and in most of the cases people have suggested to go for UDF to get the desired  TIME format. I hope this blog will be very useful for beginners. Here in this blog i am explaining how to convert time format in different approaches with out udf  .

Let’s say we have incoming dates as  05/04/20112 23:57:47 & 06/04/2012 00:01:15 and  we want to get the desired output as 05/04/20112 11:57:47 PM and 06/04/2012 00:01:15 AM

To get the above result we don’t need to write any UDF, it is simply possible by using standard  functions.

Input: we have to provide CurrentDate function or input parameter.

Approach 1: by using some standard functions for practice

Example 1 : with currentDate

Open the “currentDate” function of the Date Function Group and double click  and then selected format (mm/dd/yyyy hh:mm:ss )  and  “Target Format” as shown in below picture.

/wp-content/uploads/2012/04/currentdate_91392.jpg

Step2: Mapping logic as converted from input  like “mm/dd/yyyy HH:mm:ss” to  “mm/dd/yyyy hh:mm:ss AM/PM”

/wp-content/uploads/2012/04/timef_91393.jpg

finally the result is :

/wp-content/uploads/2012/04/currop_91394.jpg

example2: Repeat the above logic with  “Input parameter” and here we have taken “SYSTEM”  as Input parameter.

/wp-content/uploads/2012/04/system_91395.jpg

result is:

/wp-content/uploads/2012/04/pm_91396.jpg

/wp-content/uploads/2012/04/am_91397.jpg

Approach 2: By using Standard Function “dateTrans”:

we have to select dateTrans Function of the Date Function Group then double click  and select input parameter and out parameters based on requirement.

for ex:

/wp-content/uploads/2012/04/datet_91616.jpg

note : if we need hours is 12 hours format then we have to change maually hours HH to  hh and add a letter end of the parameter as like showing in picture .

output is :

/wp-content/uploads/2012/04/op_91617.jpg

Thanks,

6 Comments
You must be Logged on to comment or reply to a post.