I want to convert 'dd' that is a number that indicate Data device (dd is in second).
At the moment I can extract the Year, Month, Day, Hour with this query in Azure Stream Analytics:
DATEPART(YEAR, DATEADD(MILLISECOND, dd, '1970-01-01')) AS [Year],
DATEPART(MONTH, DATEADD(MILLISECOND, dd, '1970-01-01')) AS [Month],
DATEPART(DAY, DATEADD(MILLISECOND, dd, '1970-01-01')) AS [Day],
DATEPART(HOUR, DATEADD(MILLISECOND, dd, '1970-01-01')) AS [Hour]
I want to extract the DateTime from dd, so after that i can insert on a database.
Can someone help me?
If I understand, you simply need only to calculate the date from the Epoch.
--If dd is milliseconds NOTE : This could cause error as DATEADD does not use BIGINT for conversion
DECLARE @MyDate DATETIME = DATEADD(MILLISECOND, dd, '1970-01-01')
--If dd is seconds. The safer route.
DECLARE @MyDate DATETIME = DATEADD(SECOND, dd, '1970-01-01')
流分析支持基于JavaScript的UDF,您可以尝试一下
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.