Hi,
I have some issues with date which I get through API as text like this "05/27/1995 12:00:00 AM" I tried all of the built-in functions like FormatDateTime, Replace / to - and so on. Every time it retunes the null date like "1900-01-01 00:00:00". Is there something which can help me to get the correct date like "1995-05-27 00:00:00"
Hi Nabi,
Unfortunately, I'm not aware of any forge asset that addresses your requirement. Defining a custom logic/solution is the other option which you can opt, as Gee suggested.
If the DateTime value format from the API remains the same on all occurrences then you can also try the below-mentioned implementation.
Implementation Steps:
Demo screen: FormatDateTimeToDateTask
Refer to the attached oml.
I hope this helps you!
Kind regards,
Benjith Sam
I presume that, you want the API's response DateTime text converted Date value in the screen scope. One of the approaches would be to use JS.
JS Snippet:
var dt = new Date($parameters.DateTimeText); $parameters.DateText = dt.getFullYear() + "-" + (dt.getMonth() + 1) + "-" + dt.getDate();
Hi Sam,
Thank you for your response this approach is for client action what is I am using server Action because we don't have JS in server action.
Hi @M.Nabi,
there is an alternate way to convert the DateTime string and am not sure this will be the best practice. But am sure this solution will help you to resolve the issue.
you can re-struct the regex format which requires as per your scenario.
Thank you, Kay,