Reputation: 17
My scenarios is that sensors always store data at local,sometime these data will be uploaded to Event Hub but I don't need all the data,I need filter data by a time field in Azure Stream Analytics. But Azure Stream does not have GETDATE() or CURRENT_TIMESTAMP. Is there any other alternatives ?
SELECT
devId,
dataType,
utc
INTO
into
FROM
output
WHERE
(TRY_CAST(utc AS bigint) IS NOT NULL) AND
(DATEADD(millisecond, utc, '1970/01/01 GMT') >= DATEADD(minute,-5,CURRENT_TIMESTAMP))
Upvotes: 1
Views: 3203
Reputation: 715
You can use System.Timestamp like here and also filter/group by for a given time window:
SELECT * INTO ArchiveOutput FROM Input TIMESTAMP BY Time
SELECT Make, System.TimeStamp AS Time, COUNT(*) AS [Count] INTO AlertOutput FROM Input TIMESTAMP BY Time GROUP BY Make, TumblingWindow(second, 10) HAVING [Count] >= 3
You have many other examples here https://azure.microsoft.com/en-us/documentation/articles/stream-analytics-stream-analytics-query-patterns/#query-example-find-last-event-in-a-window
Upvotes: 2