Dennis vd Eijnde
Dennis vd Eijnde

Reputation: 303

Microsoft query format function with SQL Server data

How can I get the ISO week/year from a date using Microsoft Query. I used to use the following WHERE statement:

WHERE (format([Date],'ww',2,2)=format(?,'ww',2,2))

The ? is the date parameter I used. the ,2,2 extension is making sure the result is according to the ISO for dates.

This worked when I used tables where Access was the data source. Now I'm trying to get the same result but then with SQL Server tables as datasource. I tried using:

datepart(ISO_week, [Date]) = datepart(ISO_week, ?)

But parameters don't seem to work in functions when using SQL Server data.

I load SQL Server tables in Excel using Microsoft Query. I do this so I can use parameters in my querys.

Upvotes: 0

Views: 182

Answers (1)

Dennis vd Eijnde
Dennis vd Eijnde

Reputation: 303

When using SQL Server data tables, functions using the '?' parameter sign didn't seem to work. So instead I made a field in Excel where the function is performed so that I can use that value in the query

Upvotes: 0

Related Questions