> Is there a way to select the datepart(mydate,"mm/dd/yy") > from MSSQL? I can only seem to return the Day, month or > year, but not all three. The field contains date & time data > and I am trying to group on the date part but the time is > throwing off the results.
I _think_ this will work ... GROUP BY DATEPART(yyyy,mydatecolumn), DATEPART(dy,mydatecolumn) but don't quote me... You can also ( if necessary ) construct an alias column in a view which would include only the date portion as such: SELECT CONVERT(smalldatetime, (STR(DATEPART(mm,mydatecolumn)) + '/' + STR(DATEPART(dd,mydatecolumn)) + '/' + STR(DATEPART(yyyy,mydatecolumn)) ) ) AS DateAtMidnight If you're using SQL Server 2000, you can create a user-defined function in SQL server to encapsulate the above CONVERT() statement to make is easier, that way you could say define the function as dbo.DateAtMidnight(@mydate) and then use SELECT dbo.DateAtMidnight(mydatecolumn) in your query... hth Isaac Dealey Certified Advanced ColdFusion Developer www.turnkey.to 954-776-0046 ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists