Tuesday 16 June 2015

BI Publisher: Format Date in XML/BI Publisher

I have seen few questions in OTN on formatting Date in BI Publisher. One of the responses given in one of the thread looks like something which is not available easily(atleast for me) on googling. So I will post the solution here as it might help someone.

Refer : Extended Function Support in RTF Templates

OTN Thread : https://community.oracle.com/message/13125600#13125600

SQL Statement or XSL Expression Usage Description
format_date() <?xdoxslt:format_date(./AnyDate,'yyyy-MM-dd','MM/dd/yyyy', $_XDOLOCALE, $_XDOTIMEZONE)?> Reads date in one format and creates in another format.

First one ('yyyy-MM-dd') is the output format and the second one ('MM/dd/yyyy') is the input format.

Sample XML:
 <INVOICES>  
      <INVOICE_DETAILS>  
           <INVOICE_DATE1>13-Jun-2015</INVOICE_DATE1>  
           <INVOICE_DATE2>13/06/2015</INVOICE_DATE2>  
           <INVOICE_DATE3>06/13/2015</INVOICE_DATE3>  
      </INVOICE_DETAILS>  
      <INVOICE_DETAILS>  
           <INVOICE_DATE1>13-Jan-2015</INVOICE_DATE1>  
           <INVOICE_DATE2>13/01/2015</INVOICE_DATE2>  
           <INVOICE_DATE3>01/13/2015</INVOICE_DATE3>  
      </INVOICE_DETAILS>  
 </INVOICES>  

Sample RTF Code:
 <?xdoxslt:format_date(INVOICE_DATE1,'dd-MMM-yyyy HH:mm:ss','dd-MMM-yyyy',$_XDOLOCALE,$_XDOTIMEZONE)?>  
 <?xdoxslt:format_date(INVOICE_DATE2,'dd-MMM-yyyy HH:mm:ss','dd/MM/yyyy',$_XDOLOCALE,$_XDOTIMEZONE)?>  

 <?xdoxslt:format_date(INVOICE_DATE3,'dd-MMM-yyyy HH:mm:ss','MM/dd/yyyy',$_XDOLOCALE,$_XDOTIMEZONE)?>  

Output:

Few other helpful blogs on this topic:

Feel free to point out if anything is missing/wrong in this blog

1 comment:

  1. Hi,

    Please explain what are these for $_XDOLOCALE, $_XDOTIMEZONE?

    Thanks and regards,
    AJ

    ReplyDelete