how to remove time from datetime

前端 未结 10 1559
清酒与你
清酒与你 2020-12-01 10:18

The field DATE in the database has the following format:

2012-11-12 00:00:00

I would like to remove the time from the date and return the d

相关标签:
10条回答
  • 2020-12-01 11:00

    just use, (in TSQL)

    SELECT convert(varchar, columnName, 101)
    

    in MySQL

    SELECT DATE_FORMAT(columnName, '%m/%d/%Y')
    
    0 讨论(0)
  • 2020-12-01 11:02

    TSQL

    SELECT CONVERT(DATE, GETDATE())         // 2019-09-19
    SELECT CAST(GETDATE() AS DATE)          // 2019-09-19
    SELECT CONVERT(VARCHAR, GETDATE(), 23)  // 2019-09-19
    
    0 讨论(0)
  • 2020-12-01 11:04

    For more info refer this: SQL Server Date Formats

    [MM/DD/YYYY]

    SELECT CONVERT(VARCHAR(10), cast(dt_col as date), 101) from tbl
    

    [DD/MM/YYYY]

    SELECT CONVERT(VARCHAR(10), cast(dt_col as date), 103) from tbl
    

    Live Demo

    0 讨论(0)
  • 2020-12-01 11:04

    You may try the following:

    SELECT CONVERT(VARCHAR(10),yourdate,101);
    

    or this:

    select cast(floor(cast(urdate as float)) as datetime);
    
    0 讨论(0)
提交回复
热议问题