sql server - T-SQL Azure Stream Analytics Rounding to Minute -
i have following select clause in azure stream analytics query:
select dateadd(mi, datediff(mi, 0, dateadd(s, 30, max(timecreated))), 0) 'timestamp'
which giving following error:
second parameter of 'datediff' in expression 'datediff ( mi , 0 , dateadd(s, 30, max ( timecreated ) ) )' has invalid type 'bigint'. 'datetime' expected.
admittedly, code i'm using copied several similar threads on stackoverflow, such t-sql datetime rounded nearest minute , nearest hours using functions, i've no idea change 0 in scenario.
it should have auto cast 0 bigint datetime, there may quirks azure version of t-sql. instead, use:
select dateadd(mi, datediff(mi, cast('1900-01-01 00:00:00.000' datetime), dateadd(s, 30, max(timecreated))), cast('1900-01-01 00:00:00.000' datetime)) 'timestamp'
Comments
Post a Comment