如何编写获取时间的查询,例如:10:3​​0.从当前日期时间在SQL Server? [英] how to write a query for get time ex:10:30. from current datetime in sql server?

查看:91
本文介绍了如何编写获取时间的查询,例如:10:3​​0.从当前日期时间在SQL Server?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,

如何编写获取时间的查询
示例:
10:30.
从当前日期时间在sql server中?


请帮助我



mohan

Dear sir,

how to write a query for get time
example:
10:30.
from current datetime in sql server?


please help me


by
mohan

推荐答案

尝试:
SELECT CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond


提供的答案OriginalGriff应该带来结果正确,但是如果要在客户端应用程序中显示时间,请考虑获取GETDATE函数返回的完整日期时间,并在客户端(而不是在查询中)设置其格式.例如,对于不同的语言,显示日期和时间的格式会有所不同,因此为了始终获得合适的格式,应在客户端进行格式化.
The answer OriginalGriff provided should bring the correct result, but if you''re going to show the time in client application, consider getting the full datetime returned by GETDATE function and format it at the client side, not in the query. For example for different languages the format of showing the date and time varies so to always get a suitable format the formatting should be done at client side.


选中此
SQL Server日期格式 [
Check this
SQL Server Date Formats[^]


这篇关于如何编写获取时间的查询,例如:10:3​​0.从当前日期时间在SQL Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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