Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: How to remove the time part from a field in sql server database when I make a select Date: Sat, 15 Mar 2014 17:31:49 +0100 Organization: Erland Sommarskog Lines: 16 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: mx05.eternal-september.org; posting-host="fd3d6d0229f14a752f017d8f9903addd"; logging-data="29037"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19wrXFjEVHoXI61bRut+uJw" User-Agent: Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32) Cancel-Lock: sha1:n3beP1hWRiGAvkrGKtONEp32qwk= Xref: csiph.com comp.databases.ms-sqlserver:1734 Tony Johansson (johansson.andersson@telia.com) writes: > In this method GetBokningar I fetch all rows and return a DataSet but I > hope I can remove the time part in some way. Now I get for example > format 2013-03-12 00:00:00 for columns BokningFromDate and BokningToDate > because these are DateTime column in the database. I could use a > DataReader and convert to string but I hope I can fix it within sql in > some way. Presentation issues are best done in the UI, but you could use the data type date throughout in the database. Or you could do convert(date, BookingFromDate) -- Erland Sommarskog, Stockholm, esquel@sommarskog.se