Thanks -----Original Message----- From: Joe Rinehart [mailto:[EMAIL PROTECTED] Sent: Friday, December 31, 2004 1:51 PM To: CF-Talk Subject: Re: Extract year from date field
> How do I extract the year from a date field such as 2005-10-12? > <cfquery name="populatedropdown" datasource="test"> > select distinct(datepart(m,report_date)) as month from report > where datepart(yy,report_date) = '2005' > </cfquery> Not to be a wiseass...but if that's the query, it'll always be 2005 :) It looks like your query gets all of the months of reports from 2005. If you wanted to get all of the distinct years for all reports, you could do the following: <cfquery name="populatedropdown" datasource="test"> select distinct(datepart(yy,report_date)) as reportYear from report </cfquery> <cfoutput query="populatedropdown">#reportYear# </cfoutput> -Joe -- For Tabs, Trees, and more, use the jComponents: http://clearsoftware.net/client/jComponents.cfm ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Silver Sponsor - CFDynamics http://www.cfdynamics.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189078 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54