Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1730

How to remove the time part from a field in sql server database when I make a select

From "Tony Johansson" <johansson.andersson@telia.com>
Newsgroups comp.databases.ms-sqlserver
Subject How to remove the time part from a field in sql server database when I make a select
Date 2014-03-15 14:37 +0100
Organization A noiseless patient Spider
Message-ID <lg1l34$knv$1@dont-email.me> (permalink)

Show all headers | View raw


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.

public DataSet GetBokningar()
  {
   Command.Parameters.Clear();
   Connection.Open();

   Command.CommandText = "SELECT BokningFromDate, BokningToDate, Name, 
Address, Phone, ProductID, EnhetsPris " +
          "FROM Bokningar " +
          "INNER JOIN Customers " +
          "ON Bokningar.CustomerID = Customers.CustomerID " +
          "INNER JOIN BokningDetails " +
          "ON Bokningar.BokningarID = BokningDetails.BokningarID " +
          "ORDER BY Name asc";

   dataAdapter = new SqlDataAdapter(Command);
   DataSet ds = new DataSet();
   dataAdapter.Fill(ds, "Products");
   return ds;
  }

//Tony 

Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

How to  remove the time part from a field in sql server database when I make a select "Tony Johansson" <johansson.andersson@telia.com> - 2014-03-15 14:37 +0100
  Re: How to  remove the time part from a field in sql server database when I make a select "Tony Johansson" <johansson.andersson@telia.com> - 2014-03-15 16:58 +0100
  Re: How to remove the time part from a field in sql server database when I make a select Erland Sommarskog <esquel@sommarskog.se> - 2014-03-15 17:31 +0100

csiph-web