A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

sorting columns in crosstab



 
 
Thread Tools Display Modes
  #1  
Old September 8th, 2005, 08:38 PM
monia13
external usenet poster
 
Posts: n/a
Default sorting columns in crosstab

I have months (MMM-YYYY) in the columns in the crosstab query. I need to
sort them according to time and not alpahnumeric. With MMM-YYYY formt they
are listed ini alphabetical order, so Apr-2005 appears before Oct-2004. Any
ideas how to accomplish this?
  #2  
Old September 8th, 2005, 09:19 PM
KARL DEWEY
external usenet poster
 
Posts: n/a
Default

Use MM MMM-YYYY

"monia13" wrote:

I have months (MMM-YYYY) in the columns in the crosstab query. I need to
sort them according to time and not alpahnumeric. With MMM-YYYY formt they
are listed ini alphabetical order, so Apr-2005 appears before Oct-2004. Any
ideas how to accomplish this?

  #3  
Old September 8th, 2005, 09:28 PM
Eric D via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

Add another column to your query.

MyDate: FormatDateTime([YourDateField], 2)
Sort by this column


monia13 wrote:
I have months (MMM-YYYY) in the columns in the crosstab query. I need to
sort them according to time and not alpahnumeric. With MMM-YYYY formt they
are listed ini alphabetical order, so Apr-2005 appears before Oct-2004. Any
ideas how to accomplish this?



--
Message posted via http://www.accessmonster.com
  #4  
Old September 8th, 2005, 09:38 PM
Michel Walsh
external usenet poster
 
Posts: n/a
Default

Hi,



ORDER BY CDate( "1-" & monthAndYear )



I assume that "1-Oct-2004" is a valid date, with your Regional Settings.



Hoping it may help,
Vanderghast, Access MVP





"monia13" wrote in message
...
I have months (MMM-YYYY) in the columns in the crosstab query. I need to
sort them according to time and not alpahnumeric. With MMM-YYYY formt
they
are listed ini alphabetical order, so Apr-2005 appears before Oct-2004.
Any
ideas how to accomplish this?



  #5  
Old September 8th, 2005, 09:45 PM
MGFoster
external usenet poster
 
Posts: n/a
Default

monia13 wrote:
I have months (MMM-YYYY) in the columns in the crosstab query. I need to
sort them according to time and not alpahnumeric. With MMM-YYYY formt they
are listed ini alphabetical order, so Apr-2005 appears before Oct-2004. Any
ideas how to accomplish this?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The usual way is to set up the date as a numeric instead of an
alphanumeric. E.g.:

Apr-2005 would be shown as 2005/04 - Format(Date_Column,"yyyy/mm")

If you know the date range (years) you can set up the PIVOT clause like
this:

PIVOT Format(date_column,"yyyy/mm")
IN ("Jan-2005","Feb-2005","Mar-2005")

--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQyCi2YechKqOuFEgEQLAigCfTEJppwN9+2OrBBChB2kk56 DP0wwAoMIa
aTcIErZD87MTBYW7f1P5OYRm
=RzoV
-----END PGP SIGNATURE-----
  #6  
Old September 8th, 2005, 11:48 PM
MGFoster
external usenet poster
 
Posts: n/a
Default

MGFoster wrote:

PIVOT Format(date_column,"yyyy/mm")
IN ("Jan-2005","Feb-2005","Mar-2005")


That should be

PIVOT Format(date_column,"mm-yyyy")
IN ("Jan-2005","Feb-2005","Mar-2005")

--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)
  #7  
Old September 9th, 2005, 02:14 AM
Duane Hookom
external usenet poster
 
Posts: n/a
Default

A third try:
That should be

PIVOT Format(date_column,"mmm-yyyy")
IN ("Jan-2005","Feb-2005","Mar-2005")

I don't ever use date values as headings in a crosstab. Next month, this
query won't work. Relative months are much more flexible.

--
Duane Hookom
MS Access MVP


"MGFoster" wrote in message
ink.net...
MGFoster wrote:

PIVOT Format(date_column,"yyyy/mm")
IN ("Jan-2005","Feb-2005","Mar-2005")


That should be

PIVOT Format(date_column,"mm-yyyy")
IN ("Jan-2005","Feb-2005","Mar-2005")

--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Columns in a Crosstab Query as fields in another query Amy E. Baggott Running & Setting Up Queries 9 August 30th, 2005 10:53 PM
Bar Chart - Sorting Columns Descending Peter Leman General Discussion 0 June 20th, 2005 04:15 PM
sorting two columns together bullseye Worksheet Functions 1 June 15th, 2005 08:43 PM
sorting order of columns in access David Database Design 7 February 22nd, 2005 02:04 AM
Re : Sorting columns by text colour melvinc74 Worksheet Functions 2 February 21st, 2004 12:47 AM


All times are GMT +1. The time now is 12:46 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.