Expand my Community achievements bar.

Dive in, experiment, and see how our AI Assistant Content Accelerator can transform your workflows with personalized, efficient content solutions through our newly designed playground experience.
SOLVED

Setting dateTime precision to milliseconds

Avatar

Level 1

We are leveraging an AJO custom action to integrate our journey with an internal API. This API takes a datetime argument in UTC format as follows: yyyy-MM-ddT HH:mm:ss.SZ (ie. 2023-12-01T23:59:59.000Z).

 

We are attempting to use the nowWithDelta() function within the request parameters of this custom action. The challenge we are running into is the function returns a datetime more precise than what is accepted by the API. The example below will return a value of 2023-11-14T13:15:58.408771377Z:

 

nowWithDelta(7, "days", "UTC")

 

What I'm hoping someone can help with is formatting this datetime to return a datetime with precision at milliseconds. From the example above, that would be  2023-11-14T13:15:58.409Z. Is there a way to do this formatting with functions available in AJO custom action request parameters?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee

@awilsonL1 

You can try something like this

toDateTime((substr(toString(nowWithDelta(7, "days", "UTC")), 0, 23)) + 'Z')

View solution in original post

3 Replies

Avatar

Community Advisor

@awilsonL1, Can you apply toDateTime conversion function along with nowWithDelta function to get the desired UTC format? Refer to this documentation page.

Thanks, Sathees

Avatar

Level 1

Thanks for the response!

 

This conversion function is one of the things we did explore but the nowWithDelta() function already returns a dateTime object. Thus, if we attempt to pass in the result of that function to the toDateTime() conversion function, it recognizes the input as being invalid for the purpose of conversion. The toDateTime() function is expecting either a string, integer or dateTimeOnly data type for input.

Avatar

Correct answer by
Employee

@awilsonL1 

You can try something like this

toDateTime((substr(toString(nowWithDelta(7, "days", "UTC")), 0, 23)) + 'Z')