473,385 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Recategorise Date Results

Hi.

I'm trying to sort an existing categorising query to categorise by financial years. I've managed that, but it won't re-categorise once the extra calculation fields are added. Any ideas?
Expand|Select|Wrap|Line Numbers
  1. SELECT   [CM Database].[Age Range],
  2.          Count([CM Database].[Age Range]) AS [Count],
  3.          Year([Date Contacted])-IIf([Date Contacted]<DateSerial(Year([Date Contacted]),4,1),1,0) AS FinYr,
  4.          [FinYr] & "/" & Right(([FinYr]+1),2) AS [Financial Year]
  5. FROM     [CM Database]
  6. GROUP BY [CM Database].[Age Range],
  7.          Year([Date Contacted])-IIf([Date Contacted]<DateSerial(Year([Date Contacted]),4,1),1,0),
  8.          [FinYr] & "/" & Right(([FinYr]+1),2)
  9. HAVING   ((([CM Database].[Age Range]) Is Not Null)
  10.    AND    ((Year([Date Contacted])-IIf([Date Contacted]<DateSerial(Year([Date Contacted]),4,1),1,0))=[Year]))
  11. ORDER BY [CM Database].[Age Range];
Feb 19 '10 #1
1 1215
NeoPa
32,556 Expert Mod 16PB
This post has been split from another thread. I couldn't see any relevance to that thread but it is at Connection ACCESS 2007 with SQL Performance in case that's important. I expect, as a new poster, you're simply unaware of some of the dos & don'ts related to posting on our forums. A quick browse through the Help link at the top of each page will help you there I'm sure.

Firstly, I have tidied up your post somewhat to make it easier to read, with code tags etc. Please note and follow suit in future.

The question probably made sense to you when you wrote it down, but from the perspective of someone who doesn't already know what you're thinking, it's a bit confusing. I'll hazard a guess and you can explain further if I'm wide of the mark. Please remember in future that, for much better results, it does help to read your post back after posting to make sure it conveys what you intend.

In this case, I think you're (probably) falling over conversion issues. Where you are dealing with dates or numbers, it is better to leave the data as dates or numbers until all processing has been finished (IE. Don't convert then try to use the converted results for any further categorisations). Converting numbers to formatted strings, or dates to either numbers or formatted strings, inhibits the ability further down the line of processing the items in their native form. You are reduced to treating them in their new form(s) which can be restricting.

I hope this resolves your issue and Welcome to Bytes.
Feb 21 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: paulus4605 | last post by:
Dears I have the following problem I’m using a query to get all the data from my database from the past year the second query is displaying the results by month. How can I match the second...
6
by: Thomas Scheiderich | last post by:
I have the following page as test.aspx: *************************************************** <html> <head> <title>Hello and Welcome Page</title> </head> <body> <center> <% Dim CurrentDate As...
1
by: Neo Geshel | last post by:
I am having conflicting results with two pieces of identical code. One is an insert, the other is an update to a db. The first code, which works, is this: Sub Add3_Click(sender As Object, e As...
6
by: supasnail | last post by:
I've been going round in circles here trying to get this to work and my ignorance of ASP is now showing me up. I want to construct a query string to allow me to filter entries to be displayed on...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
2
by: milo1955 | last post by:
I have a form that passes a single variable via the GET function to a mysql databse query with the results paginated. The first page of the results work fine, but the link to the second page yields...
3
by: Jensen.Katie | last post by:
I have a SQL Server 2005 DB that I set up an ODBC connection to so that people can access the data through MS Access. There are 3 tables, each of which have a date column that is a varchar (20)...
2
hodgeman
by: hodgeman | last post by:
My second thread on thescripts, so hoping to get the same feedback and help as last time... I've developed an online invoicing and payment system for all my accounts for my web design company....
1
by: Arli | last post by:
I have the following linked tables: tblMainPL is my main table that I need to pull the information in from. It has the following fields: Autonumber1 -PK set as autonumber Date - short date...
1
by: blondieUA | last post by:
Hello guys! I have some problem with creating the result page :( I need to create a web-page for my college course in Computer Science. I decided to create a site about Horoscopes. So if a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.