L
Lee
Hello,
I am beginning query builder. I have a select query which should extract sales data for one month after the user is prompted for the year and month. It should display the sales totals for each category with the month name written out. I want to use it to create a monthly report of sales.
The problem is I can run it without the Format function and get the month to display correctly as a number but if I try to use Format to get the month name I get the wrong month. If I enter 1 (for January) I get Dec, 2 (for February) I get Jan, 12 (for December) I get Jan. Why is this happening and how can I get the correct month to print out?
I also tried separating the Format and DatePart statements with no good effect.
The SQL follows:
Thanks for your help.
SELECT Format(DatePart("m",[DateSequenced]),"mmm") AS [Month], Prices.ProcedureName, Sum(Prices.Price) AS Charges
FROM Prices INNER JOIN Sample ON Prices.PriceCode = Sample.PriceCode
WHERE (((DatePart("yyyy",[DateSequenced]))=[enter year]) AND ((DatePart("m",[DateSequenced]))=[enter month]))
GROUP BY Format(DatePart("m",[DateSequenced]),"mmm"), Prices.ProcedureName;
I am beginning query builder. I have a select query which should extract sales data for one month after the user is prompted for the year and month. It should display the sales totals for each category with the month name written out. I want to use it to create a monthly report of sales.
The problem is I can run it without the Format function and get the month to display correctly as a number but if I try to use Format to get the month name I get the wrong month. If I enter 1 (for January) I get Dec, 2 (for February) I get Jan, 12 (for December) I get Jan. Why is this happening and how can I get the correct month to print out?
I also tried separating the Format and DatePart statements with no good effect.
The SQL follows:
Thanks for your help.
SELECT Format(DatePart("m",[DateSequenced]),"mmm") AS [Month], Prices.ProcedureName, Sum(Prices.Price) AS Charges
FROM Prices INNER JOIN Sample ON Prices.PriceCode = Sample.PriceCode
WHERE (((DatePart("yyyy",[DateSequenced]))=[enter year]) AND ((DatePart("m",[DateSequenced]))=[enter month]))
GROUP BY Format(DatePart("m",[DateSequenced]),"mmm"), Prices.ProcedureName;