on 07-15-2016 2:11 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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)/'.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.