Click here to Skip to main content
15,906,081 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am getting nowhere transforming this VBA query in MS Access 2010 to VS 2010 Linq query to the MVC3 table model. This gets the last 10 quarters of the format "yyyy q""Qtr""" => sample: 2011 4Qtr. The 10 items are listed in a comboBox for selection to create an annual report starting from the selected quarter.

The easy way is to generate the string from today's date, not from the repository data. This is for learning purposes, so your help is appreciated if you got the time.

This is the VBA query:
SQL
SELECT TOP 10 Format([tblModel].[Dtime],"yyyy q""Qtr""") AS YearQ
        FROM tblModel
        GROUP BY Format([tblModel].[Dtime],"yyyy q""Qtr"""), 10
        HAVING (((Format([tblModel].[Dtime],"yyyy q""Qtr"""))<=Format(DateAdd("yyyy",-1,Date()),"yyyy q""Qtr""")))
        ORDER BY Format([tblModel].[Dtime],"yyyy q""Qtr""") DESC;

In C#, there is no "q" quarter format, and no Having method in Linq. Your guide and suggestions are appreciated.
Posted
Updated 10-Jan-12 20:09pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900