我如何从SQL Server获取时间 [英] How can i get Time from SQL Server

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

问题描述

大家好,

我的表有一个字段名称"Docdate".该字段的存储方式为"2006-01-05 00:00:00.000".有时间吗?
例如:09:35或10:24分钟.

如果可能的话,我该怎么办?

谢谢

TONY

解决方案

如果存储的日期不具有时间值,那么您很不走运,如果没有,请阅读以下内容:
http://stackoverflow.com/questions/3201432/how-to-get-time-part-from-sql-server-2005-datetime-in-hhmm-tt-format [此处 [日期时间格式 [ ^ ]

否则

试试这个:

  SELECT  LTRIM( RIGHT ( CONVERT ( VARCHAR ( 20 ),GETDATE(), 7 ))


Hi all,

My table has one field name "Docdate". This field is stored like this "2006-01-05 00:00:00.000". Is it possible to get Time?
Ex: 09:35 or 10:24 minute.

If it is possible,How can i do?

Thanks

TONY

解决方案

If the date stored does not have the time value then you are out of luck, if not then read this :
http://stackoverflow.com/questions/3201432/how-to-get-time-part-from-sql-server-2005-datetime-in-hhmm-tt-format[^]


If you have stored the time as 00:00:00 then you won''t be able to get the time.

Change the frontend code to pass in an appropriate time value.
Once that is done, you can pick up the time as described here[^].


Yes you can, please refer Date time formats[^]

Or else

Try this:

SELECT LTRIM(RIGHT(CONVERT(VARCHAR(20), GETDATE(), 100), 7))


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

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