Your SQL Statement looked correct, can you post the error message your getting?
Main Topics
Browse All TopicsHi,
I think this is a simple question but I am just not sure how to do it right, as a newbie.
All I want to do is generate a report of company employees grouped by their date of hire.
SELECT DateOfHire, FirstName, LastName from Empls
ORDER BY DateOfHire
The only problem is that the DateOfHire displays as, e.g., '01/03/2004 12:00:00' which is not what I want. I SIMPLY WANT TO OMIT THE TIME PART but don't know quite how to say this. I tried several variations along this line but it causes scoping errors...
SELECT CONVERT(Varchar(10), DateOfHire, 101) AS DOHDateOnly, FirstName, LastName, State
FROM EMPL
GROUP BY DOHDateOnly
but this gives error
"The value expression for the textbox ‘DateOfHire’ refers to the field ‘DOHDateOnly’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope."
Which makes sense, but I don't know HOW to say the right thing to get what I want.
Any help will be greatly appreciated. Need quick response, points assigned accordingly.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well, I found some sort of resolution but it isn't really adequate...
With
SELECT CONVERT(varchar(10), DateOfHire, 101) AS 'MM/DD/YY', FirstName, LastName, State
FROM EMPL
and then specifying GROUP BY MM_DD_YY
BUT THE PROBLEM NOW is that since it is converted to a string, the sorting order is different and not what I want. I want to be able to print the records in sort order of ascending date, but of course, I am getting all the Januarys first, etc. ARRRRRRRRRRRGGGGGGGGGGGGGG
Any thoughts on how to get this to happen? I am sure that I somehow need to break it into pieces to get to the year first, etc but not sure of the right approach.
Thanks for any additional help.
Actually, Navicerts, that did sort of work. THe only issue is that I wanted to be able to group them by date, and that is where it goes awry and uses character sort order.
As long as I am happy with having the dates simply listed, and not "grouped" then I can at least get the data in the right order.
However, my report would look a lot nicer if I were able to group by ascending date. Otherwise, it's kind of a ...data grid.
If this is what we have to live with for now, so be it. But if this tidbit of information jogs anything in your memory about how to get them sorted AND grouped, would be much appreciated.
Thanks for all your help so far. I'll wait a bit to see if you have any further wisdom to share, before awarding the points...
THanks again
zoseri
You can only group by your least common denominator in the query itself, for instance with the following data you would have to group by date, name and state....
1/1/2005 Bob FL
1/1/2005 Jane TX
1/1/2005 Joe AL
However if your data looked like this...
1/1/2005 Jane FL
1/1/2005 Jane FL
1/1/2005 Jane FL
And you grouped by all three it would yield a result like this...
1/1/2005 Jane FL
Perhaps you already understood this and i misunderstood the question, sorry if thats the case, hope this helps.
-Navicerts
This thread if over 3 years old :) I only noticed because it generated an email to me. You may want to make a new question and see if anyone knows in the Oracle forum. Maybe check this out too... http://infolab.stanford.ed
Old question....
I don't use Oracle, but try this...
http://infolab.stanford.ed
Whenever a DATE value is displayed, Oracle will call TO_CHAR automatically with the default DATE format. However, you may override the default behavior by calling TO_CHAR explicitly with your own DATE format. For example,
SELECT TO_CHAR(b, 'YYYY/MM/DD') AS b
FROM x;
returns the result:
B
--------------------------
1998/04/01
Business Accounts
Answer for Membership
by: simon_kirkPosted on 2005-07-14 at 01:16:09ID: 14438489
Think you just need to include the scope for your field, something like:
ASET")
Fields(DateOfHire,"YOURDAT