【问题标题】:How to convert any time in yyyy-mm-dd hh:mi:ss.mmm to yyyy-mm-dd hh 00:00:00.000 [duplicate]如何将 yyyy-mm-dd hh:mi:ss.mmm 中的任何时间转换为 yyyy-mm-dd hh 00:00:00.000 [重复]
【发布时间】:2014-06-08 20:39:31
【问题描述】:

当使用 getdate() 时,例如,2014-04-23 15:51:31.763

我想要2014-04-23 00:00:00.000

我怎样才能做到这一点?

【问题讨论】:

标签: sql sql-server


【解决方案1】:

将其更改为简单日期格式为 yyyy-mm-dd 然后将其转换回 yyyy-mm-dd-xx:xx:xx:xxx 然后时间戳将被删除并重置为零

【讨论】:

    【解决方案2】:

    已发布并回答了一个类似的问题:

    How to return the date part only from a SQL Server datetime datatype

    但是,要实现您的确切愿望:

    选择转换(日期时间,转换(日期,getdate()))

    【讨论】:

      猜你喜欢
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-22
      • 2011-03-18
      • 1970-01-01
      相关资源
      最近更新 更多