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

Invalid datetime error for the uploaded files

SA-39268

Summary



The date format given in the upload files is "mm/dd/yyyy".

But in one system the expected format for date is “dd/mm/yyyy” and in another system it expects “mm/dd/yyyy”.

If user gives one format in the files to be uploaded, it fails in one or the other systems.

No difference observed with respect to systems interms of browser locales.


Error Messages



 ** 	Invalid datetime format/Invalid datetime


Steps to Reproduce



1) Upload excel files where one column of excel is a date column.
2) Let the date format in Excel be mm/dd/yyyy.

Upload was unsuccessful with an error "Invalid datetime format/invalid datetime".

Always the date format in the files would be mm/dd/yyyy for users, but one environment seems to accept one format and another environment a different one.


Root Cause



An issue in the custom application code or rules

The PRPC accepted date-format depends on the operator locale. If it's empty then it uses the browser locale or the system locale.

In this case, user might have different locales for different users but still the excel files should always be in same date format mm/dd/yyyy.

Resolution



Convert the mm/dd/yyyy format to GMT before assigning the value to a PRPC date property and check if there are any available function in PRPC converts a date string to GMT.

If no create a custom function which would do the GMT conversion using the following local-change:

Below code could be taken as a reference.

//Format accepted : mm/dd/yyyy or m/dd/yyyy

String GMT = **dateinput**;
String [] array = GMT.split("/");
//adding a zero to handle single digit date or month
if(array[0].length() == 1 )
array[0]= "0" +array[0];
if(array[1].length() == 1 )
array[1]= "0" +array[1];
GMT = array[2] + array[0] + array[1] + "T000000.000 GMT";
return GMT;

Also the time difference between timezones should be handled while conversion.


Published November 18, 2017 - 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