ribena1980 ribena1980 - 1 year ago 82
SQL Question

Sorting Month And Year Results In Microsoft Access

I have the following table in Microsoft Access


I want to run a query that shows the Profit/Loss for each month.

I have been able get a query that returns the information in the following format

TransactionDate By Month Sum Of Sum Of Profit/Loss

April 2014 €1,084.99

April 2015 €674.33

April 2016 €2,057.30

August 2014 €237.59

August 2015 -€267.82

December 2014 €375.88

December 2015 -€1,161.97

February 2015 -€603.87

February 2016 -€124.71

January 2015 €75.11

January 2016 -€1,044.35

But what I want now is for it to display in chronological order as oppose to Alphabetical order.

For example

January 2014

February 2014

March 2014


Answer Source

I will consider that your TransactionDate field is defined as String

If you want to order by this text field in Access, you will have to use DateValue() function.

That would give:

SELECT TransactionDate FROM yourTable ORDER BY DateValue(TransactionDate)

If your field is already formatted as a Date field, then simply use order by TransactionDate to make it work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download