Prev: How to save an image from SQL Server to a file using SQL
Next: using "USE dbname" before ALTER DATABASE
From: David C on 4 Nov 2009 10:33 I have a SQL 2000 database table that has a smalldatetime column that I want to remove the time portion for those that have a time. We added a new application that is "feeding" this table and the column named DateEntered has both date and time in it. For example one of the entries is 11/3/2009 7:24:00 AM and we would like it to contain 11/3/2009 only, just like the remainder of the table records. Any way to do this? Thanks. Below is sample of update code UPDATE dbo.ROTimesheets SET DateEntered = LEFT(CONVERT(CHAR(10),DateEntered,101),10) WHERE LEN(DateEntered) > 10 David
From: Uri Dimant on 4 Nov 2009 10:45
David UPDATE dbo.ROTimesheets SET DateEntered = DATEADD(d,DATEDIFF(d,0,DateEntered),0) "David C" <dlchase(a)lifetimeinc.com> wrote in message news:OKmsVRWXKHA.1268(a)TK2MSFTNGP04.phx.gbl... >I have a SQL 2000 database table that has a smalldatetime column that I >want to remove the time portion for those that have a time. We added a new >application that is "feeding" this table and the column named DateEntered >has both date and time in it. For example one of the entries is 11/3/2009 >7:24:00 AM and we would like it to contain 11/3/2009 only, just like the >remainder of the table records. Any way to do this? Thanks. > Below is sample of update code > > UPDATE dbo.ROTimesheets > SET DateEntered = LEFT(CONVERT(CHAR(10),DateEntered,101),10) > WHERE LEN(DateEntered) > 10 > > David > |