What is the alternative for Extract in Azure Datawarehouse, we are using datepart right now but it does not work with from, so what can be a straight forward alternative for extract??
Yes, the equivalent of Redshift's EXTRACT
is DATEPART
, as listed in the supported T-SQL functions of Azure DWH
DATEPART ( datepart , date )
e.g. the RedShift query
select salesid, extract(week from saletime) as weeknum
from sales
where pricepaid > 9999
order by 2;
Has the equivalent in T-SQL as
select salesid, DATEPART(ww, saletime) as weeknum
from sales
where pricepaid > 9999
order by 2;
i.e. DATEPART
does not use FROM
but instead is a function with 2 parameters - the first being the PART and the second the Date/Time to which to apply the function.