On Wed, Oct 15, 2008 at 10:38 PM, Phillip M. Vector < [EMAIL PROTECTED]> wrote:
> How do I write a query to only pull 1 year (2009 lets say) from the DB > that has a date field? > > would I do something like > > where datestarting like "%09" > > ? > > I mean, that MAY work, but is there a less kludgy way of doing it? > eek. assuming the date field is actually a date datatype, you could do: WHERE myDateField >= <cfqueryparam value="#createODBCDateTime(createDateTime(2009,1,1,0,0,1))#" cfsqltype="cf_sql_date" /> and myDateField <= <cfqueryparam value="#createODBCDateTime(createDateTime(2009,12,31,23,23,59))#" cfsqltype="cf_sql_date" /> that's ugly, but it works. prettier would be: WHERE year(myDateField) = 2009 but you lose any indexing that you might have on that column. -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313992 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

