如何格式化时间 [英] How Do I Format A Time

查看:79
本文介绍了如何格式化时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在sql server 2008 R2中格式化时间'17:15:01.7730000'到'17:15'???

解决方案

你可以使用

 CONVERT(VARCHAR(5),[Date],114)





114以格式生成日期 hh:mi:ss:mmm(24h)并且VARCHAR(5)仅返回前5个字符...即 hh:mi


尝试

SQL Server函数,有助于将日期和时间值转换为字符串文字和其他日期和时间格式。 [ ^ ]

http://blog.sqlauthority.com/2009/08/06/sql-server-get- time-in-hourminute-format-from-a datetime-get-date-part-only-from-datetime / [ ^ ]

http://technet.microsoft.com/en-us /library/ms186724.aspx [ ^

how do i format a time '17:15:01.7730000' to '17:15' in sql server 2008 R2 ???

解决方案

You can use

CONVERT(VARCHAR(5),[Date],114)



The 114 produces the date in the format hh:mi:ss:mmm (24h) and the VARCHAR(5) returns only the first 5 characters ... i.e. hh:mi


Try
SQL Server Functions that helps to convert date and time values to and from string literals and other date and time formats.[^]
http://blog.sqlauthority.com/2009/08/06/sql-server-get-time-in-hourminute-format-from-a-datetime-get-date-part-only-from-datetime/[^]
http://technet.microsoft.com/en-us/library/ms186724.aspx[^]


这篇关于如何格式化时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆