I have a Z that appears at the end of my date field

Alexis Roche 0 Reputation points
2024-09-26T07:43:45.01+00:00

Hello, I'm trying to retrieve all the data that was modified yesterday on my ERP via an API that is accessible in Odata. However, I'm having an issue with my date field, as I get the character Z appearing at the end of the variable.

I tried converting it to a string to concatenate, and also tried removing the rightmost character from my string. I saw a post suggesting to do this: formatDateTime(item().name, 'yyyy-MM-ddTHH:mm:ss:fffff', which works, but I can't keep the milliseconds. My API doesn't accept them.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,643 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Chandra Boorla 1,500 Reputation points Microsoft Vendor
    2024-09-26T15:14:12.44+00:00

    Hi @Alexis Roche

    Apologies for the inconvenience.

    As I mentioned earlier, the "Z" at the end of the formatted date-time string in your Azure Data Factory expression indicates that the time is in UTC (Coordinated Universal Time). This is a standard format used to represent time zones in ISO 8601.

    If you want to remove the Z from the end of the formatted date string, you can use the substring function to exclude the last character.

    Calculate the formatted date string without the Z:

    @substring(formatDateTime(addDays(utcnow(), -1), 'yyyy-MM-ddT00:00:00'), 0, 19)
    

    Explanation:

    formatDateTime(addDays(utcnow(), -1), 'yyyy-MM-ddT00:00:00'): This part generates the date string with the Z at the end.

    substring(<date-string>, 0, 19): This part extracts the first 19 characters of the date string, effectively removing the Z.

    This will format the date-time string in the specified format, but without the "Z" at the end.

    I hope this information helps.

    Thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.