|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Query help
I'm running a query of news items and want to sort by the date. I want the most recent news items first--so today's item will appear at the top of the list, above the one from yesterday which is above the one from next week. So my query is:
<cfquery name="getNews"> SELECT ID, newsDate, icon, headline, short_desc FROM news_items WHERE display = 1 ORDER BY YEAR(newsDate) ASC, newsDate ASC </cfquery> I've used YEAR(newsDate) ASC, newsDate ASC with multiple databases, but my current one (I believe it's Oracle) isn't having it. I'm getting an "Invalid Identfier" error. Has anyone run into this, and can you suggest a solution or someplace to look? Sorry if this is in the wrong Forum. I never know what should be where with queries. |
|
#2
|
|||
|
|||
|
This should work:
<cfquery name="getNews"> SELECT ID, newsDate, icon, headline, short_desc FROM news_items WHERE display = 1 ORDER BY to_char(newsDate, 'YYYY') ASC, newsDate ASC </cfquery>
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Thanks!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Query help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|