Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

February 21, 2000 12:00 AM

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

Windows IT Pro
InstantDoc ID #15256
Rating: (72)

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))


Related Content:

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

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.