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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |