You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Data Factory:如何将UTC datetime转换为Unix Timestamp?

Convert UTC Datetime to Unix Timestamp in Azure Data Factory

Got it, let's break down how to turn a UTC datetime string like 2021-11-08T07:25:00Z into a Unix Timestamp (like your example 1636385119) in Azure Data Factory. There are two common scenarios you'll run into—using ADF's expression language (for pipelines, datasets, etc.) and working within Data Flows.

1. Using ADF Expression Language (Pipeline/Dataset Scenarios)

ADF has built-in functions that make this straightforward. You'll need two main functions:

  • toDateTime(): Converts your UTC string into a proper datetime type (the Z suffix tells ADF this is UTC time, so no extra timezone conversion is needed here)
  • unixTimeSeconds(): Calculates the number of seconds since the Unix epoch (1970-01-01T00:00:00Z) from a datetime value

Example Expression

If you're working with a hardcoded string (like your example):

unixTimeSeconds(toDateTime('2021-11-08T07:25:00Z'))

If you're pulling the UTC datetime from a column or parameter, replace the hardcoded string with your reference:

unixTimeSeconds(toDateTime(pipeline().parameters.UTC_Datetime))

Note: If your input datetime isn't already in UTC, you'll need to adjust it using convertTimeZone() first before passing it to unixTimeSeconds().

2. Using Data Flows

If you're transforming data in a Data Flow, use a Derived Column transformation to apply the same logic:

  1. Add a Derived Column to your Data Flow.
  2. In the expression builder, use this formula (replace your_utc_datetime_column with your actual column name):
    unixTimeSeconds(toDateTime(your_utc_datetime_column, 'yyyy-MM-dd''T''HH:mm:ss''Z'''))
    
    The format string ensures ADF correctly parses the UTC string with the Z suffix.

Quick Note on Milliseconds

If you need a Unix Timestamp in milliseconds instead of seconds, just swap unixTimeSeconds() with unixTimeMilliseconds().

内容的提问来源于stack exchange,提问作者Akhilesh Jaiswal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.01 01:44:07