on ‎2023 Oct 04 10:22 AM
Hello all,
Whenever I use a date from an Odata service, it is formatted like this:

As I'm using a standard OData service (API_SALES_ORDER_SRV) I can't change the type of the field to string. Has anyone encountered this problem and can help me?
Thanks
Benedikt
Request clarification before answering.
Hello,
You can create a quick subflow with Javascript to transform those Date, adapting your data response.
You could even do this with a Formula but quite cumbersome to maintain.
I have built a function that gives me time ago (E.g. 04-10-2023 was 1 year go.)
This could be a quick add-on that you can use whenever you need to display those date.
Quentin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Quentin,
I solved it by creating a rule. The part I didn't know was that you have to convert the epoch date into a number.
FORMAT_DATETIME_LOCAL(DATETIME(NUMBER(SUBSTRING(data.A_SalesOrder1.RequestedDeliveryDate, 6,19))), "DD.MM.YYYY")
Hello team,
Just for reference for other community members,
I have used below javascript code to convert the date to oData date format.
I have fired the event once the date field is changed to call the Javascript and store it into different variable.
const inputDateTime = inputs.input1;
const date = new Date(inputDateTime);;
// Step 2: Set the time to the start of the day
date.setUTCHours(0, 0, 0, 0);
// Step 3: Format the resulting date to the desired string format
const year = date.getUTCFullYear();
// because there is no less equal to operator in oData supported by JAVASCRIPT so need to -1 in From Date.
date.setUTCDate(date.getUTCDate() - 1);
const month = String(date.getUTCMonth() + 1).padStart(2, '0'); // Months are zero-based
const day = String(date.getUTCDate()).padStart(2, '0');
const hours = String(date.getUTCHours()).padStart(2, '0');
const minutes = String(date.getUTCMinutes()).padStart(2, '0');
const seconds = String(date.getUTCSeconds()).padStart(2, '0');
var result1 = year + '-' + month + '-' + day + 'T' + hours + ':' + minutes + ':' + seconds ;
return{ result : result1 };
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @ITM_Benedikt ,
Use the below function inside formula section to change the format you wish for.
FORMAT_DATETIME_LOCAL(date/time, format)Example
FORMAT_DATETIME_LOCAL("2019-07-11T13:06:15+03:00", "DD.MM.YYYY")Output:
11.07.2019
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 11 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.