Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 t-sql 字符串函数
substring(convert(varchar, getdate(), 120),6, 11)
这将返回mm-dd hh:mm
mm-dd hh:mm
但是,我如何获得日期时间格式yy-mm-dd hh:mm?
yy-mm-dd hh:mm
非常感谢你。
好吧,convert(varchar(25), getdate(), 120)返回:
convert(varchar(25), getdate(), 120)
1 1234567890123456789 2013-08-08 01:43:49
所以改变:
substring(..., 6, 11)
至:
substring(..., 3, 14)
你会得到:
13-08-08 01:43