【问题标题】:DateTime format using t-sql string functions in SQL Server query在 SQL Server 查询中使用 t-sql 字符串函数的日期时间格式
【发布时间】:2013-08-09 13:14:45
【问题描述】:

使用 t-sql 字符串函数

substring(convert(varchar, getdate(), 120),6, 11)

这将返回mm-dd hh:mm

那么我如何获得日期时间格式yy-mm-dd hh:mm

非常感谢您。

【问题讨论】:

标签: sql-server datetime substring getdate


【解决方案1】:

嗯,convert(varchar(25), getdate(), 120) 返回:

          1
1234567890123456789
2013-08-08 01:43:49

所以改变:

substring(..., 6, 11)

收件人:

substring(..., 3, 14)

你会得到:

13-08-08 01:43

【讨论】:

    猜你喜欢
    • 2018-03-11
    • 1970-01-01
    • 1970-01-01
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-21
    相关资源
    最近更新 更多