• subscribe
February 21, 2000 12:00 AM

How can I convert a SQL date/time to just date?

Windows IT Pro
InstantDoc ID #15256

A. The SQL date/time field stores a date and time but if you have a populated table and you want to convert a column so it lists data only run the following:

update <table>
where <column>=convert(datetime,convert(char(10),<column>,101))

For example

update faq
where created=convert(datetime,convert(char(10),created,101))




ARTICLE TOOLS

Comments
  • viokiata
    2 months ago
    Dec 15, 2011

    visit this link
    [url]http://sqlserverlearner.com/2011/how-to-convert-datetime-to-date-in-sql[/url]

  • viokiata
    2 months ago
    Dec 15, 2011

    this link gives more details
    http://sqlserverlearner.com/2011/how-to-convert-datetime-to-date-in-sql

  • James
    3 years ago
    Sep 16, 2009

    Here is how i would just get the date out of a long date.
    declare @NewDate varchar(10)
    select @NewDate = convert(varchar(10),getdate(),101)

  • Abraham
    6 years ago
    Dec 04, 2006

    The site below indicates the parameter values used by MS-SQL for determining the convert output function.

    http://msdn2.microsoft.com/en-us/library/ms174450.aspx

  • rushtons
    6 years ago
    Feb 22, 2006

    How do I change the code below to filter on today's current date...not 2002-02-22

    SELECT TOP 100 PERCENT UserID, LogonTime, IP, ContextID, 'LA_LA_' AS ClientID, SessionID
    FROM AAA.dbo.OnlineUser
    WHERE CAST(FLOOR(CAST(LogonTime AS float)) AS datetime) = '2002-02-22'

You must log on before posting a comment.

Are you a new visitor? Register Here
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...