Setting dateTime precision to milliseconds | Community
Skip to main content
awilsonL1
Level 2
November 7, 2023
Solved

Setting dateTime precision to milliseconds

  • November 7, 2023
  • 1 reply
  • 1596 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mohan_Dugganab

@awilsonl1 

You can try something like this

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

1 reply

SatheeskannaK
Community Advisor
Community Advisor
November 8, 2023

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

Thanks, Sathees
awilsonL1
awilsonL1Author
Level 2
November 9, 2023

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.

Mohan_Dugganab
Adobe Employee
Mohan_DugganabAdobe EmployeeAccepted solution
Adobe Employee
December 10, 2023

@awilsonl1 

You can try something like this

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