【问题标题】:Datetime format help日期时间格式帮助
【发布时间】:2010-07-30 07:28:45
【问题描述】:

我只想要时间格式的 Hr 和 Min,所以我做到了

select convert(varchar(20),GETDATE(),108) ===>> output is "12:57:54"

但我只想要“12:57”这么多,所以我将如何在 sql server 中做到这一点

【问题讨论】:

    标签: sql sql-server tsql datetime datetime-format


    【解决方案1】:

    选择转换(varchar(5),GETDATE(),108)

    【讨论】:

      【解决方案2】:

      Select cast(DatePart(hour, getdate()) as varchar(2)) + ':' + cast(DatePart(minute, getdate())as varchar(2))

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-02-24
        • 2020-11-21
        • 2011-05-10
        • 2017-11-02
        • 2014-02-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多