cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with HANA Date Format

Former Member
0 Kudos

Hi,

   I am trying Develope UI5 application using SAP HANA Extended Application Services. I am facing an issue with date format. As of now i am using json odata model for connection.  i have created one XMl View through which user can Upload a . CSV File and after uploading it

Data is Inserting in the Hana DB Table Using Odata.But Iam Facing a issue with Date Format. in CSV Date Fornat is  MM/DD/YYYY . But it is not accepting in HANADB.  it is only accepting this Value " "/Date(-210866803200000)/" not that Data Format

here is the screenshot

Thanks and Regards,

Shardul Pandey

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Shardul,

I don't really understand your question. If you need to change your time format before updating it to the data base , you can use something like this:

var currentDate1 = new Date(parseInt(dateString));
var displayDate = currentDate1.toISOString().substring(0,10);
var year = displayDate.substring(0,4);
var month = displayDate.substring(5,7);
var date = displayDate.substring(8,10);

Best Regards,

Saumil Sharma

Former Member
0 Kudos

Hello Saumil Thanks for Your Reply

Iam upload the Date from .CSV file into in HanaDB using UI5 App.in my CSV Date Format is Like

but while inserting this Date Format is not accepting By HANADB. It is only accepting this Format

if iam uploading my CSV data is not going inside in HanaDB . and if iam Passing this as Static " /Date(-210866803200000)/" than only it is accepting  

so i guess i have change My Date format at run time to  this "/Date(-210866803200000)/" Format

pfefferf
Active Contributor
0 Kudos

Hello Shardul,

OData accepts Date/Time values only in that form according to the EDM.DateType specification ( JSON Format (OData Version 2.0) - Primitive Types). Most UI5 controls dealing with times and dates have an integrated conversion mechanism to handle the format.

If you have to do the conversion by your own, you can create a new Date object (e.g. new Date(2016,07,16)) and get the milliseconds value with function getTime (e.g. myDateObject.getTime() -> '1471298400000'). With that you can form the required value '/Date(1471298400000)/'.

Regards,

Florian

Former Member
0 Kudos

Any sample Code available ?

if iam giving 2016/2/02 this format  iam not able to insert the data, and if i put " /Date(1480896000000)/ "  


than only it is accpeting !  how can i convert my 2016/2/02 this format to this /Date(1480896000000)/

pfefferf
Active Contributor
0 Kudos

As I wrote above. Create a JS Date object, get the milliseconds since 1970 with method getTime and create the required string (consider you only have to do this in case you are not dealing with standard UI5 controls which implements that behavior already).

For instance you can create a helper function like that:


function convDateToODataFormat(sDate){

    return '/Date(' + new Date(sDate).getTime() + ')/';

}

When you call it like


convDateToODataFormat('2016/2/02')

it returns the result '/Date(1454367600000)/'.

agentry_src
Active Contributor
0 Kudos

Discussion successfully moved from SAP HANA Cloud Platform Developer Center to SAP HANA Developer Center

as the more appropriate community for this topic.

Regards, Mike (Moderator)

SAP Technology RIG