Tags: birthday, database, datetime, employee, field, message, microsoft, mysql, oracle, server, sql, table, time, truncate

How to truncate the time part of a DateTime field

On Database » Microsoft SQL Server

1,380 words with 2 Comments; publish: Mon, 02 Jun 2008 01:06:00 GMT; (250250.00, « »)

I have a table about employee, there a DateTime field Birthday in it.

There are time message in some employee's birthday field.

How to truncate the time part of a DateTime field?

All Comments

Leave a comment...

  • 2 Comments
    • Try,

      update employee

      set birthday = convert(char(8), birthday, 112)

      go

      AMB

      "ad" wrote:

      > I have a table about employee, there a DateTime field Birthday in it.

      > There are time message in some employee's birthday field.

      > How to truncate the time part of a DateTime field?

      >

      >

      >

      #1; Mon, 02 Jun 2008 01:07:00 GMT
    • The example posted previously is a common method to do what you wish...

      Realize that it does NOT truncate the data type.Datetime fields always have

      the date and time... It merely sets all of the times to midnight (00:00:00).

      --

      Wayne Snyder, MCDBA, SQL Server MVP

      Mariner, Charlotte, NC

      www.mariner-usa.com

      (Please respond only to the newsgroups.)

      I support the Professional Association of SQL Server (PASS) and it's

      community of SQL Server professionals.

      www.sqlpass.org

      "ad" <ad.sqlserver.questionfor.info.wfes.tcc.edu.tw> wrote in message

      news:%23NZmeT9MFHA.1948.sqlserver.questionfor.info.TK2MSFTNGP14.phx.gbl...

      >I have a table about employee, there a DateTime field Birthday in it.

      > There are time message in some employee's birthday field.

      > How to truncate the time part of a DateTime field?

      >

      >

      #2; Mon, 02 Jun 2008 01:08:00 GMT