Format Month As Date In Access Query

geekette

Board Regular
Joined
Sep 12, 2006
Messages
120
Hi,

I have a query with a field that shows the month for each record:

Month: (Format$([DateOfData],"mmm yy"))

The query results are linked to a pivot table in Excel....my problem is that I need to sort my months in month order in the pivot table but it reads the month as text so puts them in alphabetical order instead.

How can I change this either in the pivot table or the access query (ideally in Access as I have a number of other queries I am building that will include the month)

Thank you...
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
can you just select the date normally ?
then put the date field into the pivot table, then right click on the date field in the pivot table, choose Group and Show Detail, then choose Group, then press Shift and choose Months and Years

or maybe you could select another custom field in access

SortDate: (clng(Format$([DateOfData],"yyyymm")))
so you'll get
200812
200901
200902
and so on
then you could use that field to do the sorting and the other field to do the displaying
 
Last edited:
Upvote 0
In the line

Month: (Format$([DateOfData],"mmm yy"))

just change "mmm yy" to "m yy". It will change the month from string to integer.

e.g. "Oct 08" will be shown as "10 08".

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,038
Latest member
apwr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top