Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Seconds field in date time not shown in Excel export

SA-14686

Summary



When date time content in a report is exported to Excel the seconds information is not shown correctly. Hours and minutes are correct - seconds are just missing in the Excel view.
 

Error Messages



Not Applicable


Steps to Reproduce



1.Create a ListView report with date time field where date field is of type DateTime.
2.Run the report and click on "Export to Excel" button.
3.Observe that second values of the time part is not coming in Excel report.


Root Cause

A software use or operation error 

The default date format for date field in ListView configuration does not include seconds. Thus, after exporting to Excel the value is shown in the format "d/M/yyyy hh:mm" instead of "MMM d, yyyy hh:mm:ss a".

Resolution



Perform the following local-change: 

Provided below code which will convert the date into required format.This needs to be saved in a custom control and that control to be used in "Export Excel" cell for the date field in ListView.


<div class="excel-datetime" style="vnd.ms-excel.numberformat:MMM d, yyyy hh:mm:ss a">
<%
ClipboardProperty curProp = tools.getActive();
if ((curProp.getType() == PropertyInfo.TYPE_DATE || curProp.getType() == PropertyInfo.TYPE_DATETIME)&& curProp.size() > 0 && curProp.hasValidValue() && curProp.toDate()!=null)  {
                String sDatetime="";
                String type = tools.getParamValue("DateTimeFormat");
                String strTimeZone = tools.findPage("pxRequestor").getString(".pyUseTimeZone");

                sDatetime = PRDateFormat.format(null, strTimeZone, "MMM dd,yyyy hh:mm:ss a", curProp.toDate()); 
                                                
                tools.putSaveValue("result",sDatetime); 
}
else {
                tools.putSaveValue("result",tools.getActiveValue()); 
}

%>
<pega:reference name="$save(result)" />
</div>

 



 

Published October 16, 2015 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us